CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, bool rangemode) :
    GcWindow(parent), _dateRange("{00000000-0000-0000-0000-000000000001}"), home(home), mainWindow(parent), currentRide(NULL), rangemode(rangemode), stale(true), useCustom(false)
{
    setInstanceName("Critical Power Window");

    // main plot area
    QVBoxLayout *vlayout = new QVBoxLayout;
    cpintPlot = new CpintPlot(mainWindow, home.path(), mainWindow->zones());
    vlayout->addWidget(cpintPlot);
    setLayout(vlayout);

    // controls
    QWidget *c = new QWidget;
    QFormLayout *cl = new QFormLayout(c);
    setControls(c);

#ifdef GC_HAVE_LUCENE
    // searchbox
    searchBox = new SearchFilterBox(this, parent);
    connect(searchBox, SIGNAL(searchClear()), cpintPlot, SLOT(clearFilter()));
    connect(searchBox, SIGNAL(searchResults(QStringList)), cpintPlot, SLOT(setFilter(QStringList)));
    connect(searchBox, SIGNAL(searchClear()), this, SLOT(filterChanged()));
    connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(filterChanged()));
    cl->addRow(new QLabel(tr("Filter")), searchBox);
    cl->addWidget(new QLabel("")); //spacing
#endif

    // picker details
    QLabel *cpintTimeLabel = new QLabel(tr("Duration:"), this);
    cpintTimeValue = new QLineEdit("0 s");
    QLabel *cpintTodayLabel = new QLabel(tr("Today:"), this);
    cpintTodayValue = new QLabel(tr("no data"));
    QLabel *cpintAllLabel = new QLabel(tr("Best:"), this);
    cpintAllValue = new QLabel(tr("no data"));
    QLabel *cpintCPLabel = new QLabel(tr("CP Curve:"), this);
    cpintCPValue = new QLabel(tr("no data"));

    //QFontMetrics metrics(QApplication::font());
    //int width = metrics.width("8888 watts (88/88/8888)") + 10;
    //cpintAllValue->setFixedWidth(width);
    //cpintCPValue->setFixedWidth(width); // so lines up nicely

    cpintTimeValue->setReadOnly(false);
    //cpintTodayValue->setReadOnly(true);
    //cpintAllValue->setReadOnly(true);
    //cpintCPValue->setReadOnly(true);

    QFont font = cpintTimeValue->font();
    font.setPointSize(font.pointSize());
    cpintTodayValue->setFont(font);
    cpintAllValue->setFont(font);
    cpintCPValue->setFont(font);

    cl->addRow(cpintTimeLabel, cpintTimeValue);
    cl->addRow(cpintTodayLabel, cpintTodayValue);
    cl->addRow(cpintAllLabel, cpintAllValue);
    cl->addRow(cpintCPLabel, cpintCPValue);
    cl->addWidget(new QLabel("")); //spacing

    // tools /properties
    seriesCombo = new QComboBox(this);
    addSeries();
    cComboSeason = new QComboBox(this);
    seasons = parent->seasons;
    resetSeasons();
    QLabel *label = new QLabel(tr("Date range"));
    QLabel *label2 = new QLabel(tr("Date range"));
    if (rangemode) {
        cComboSeason->hide();
        label2->hide();
    }

    cpintSetCPButton = new QPushButton(tr("&Save CP value"), this);
    cpintSetCPButton->setEnabled(false);
    cl->addRow(label2, cComboSeason);

    dateSetting = new DateSettingsEdit(this);
    cl->addRow(label, dateSetting);

    if (rangemode == false) {
        dateSetting->hide();
        label->hide();
    }

    cl->addWidget(new QLabel("")); //spacing
    cl->addRow(new QLabel(tr("Data series")), seriesCombo);
    cl->addRow(new QLabel(""), cpintSetCPButton);

    picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                               QwtPicker::VLineRubberBand,
                               QwtPicker::AlwaysOff, cpintPlot->canvas());
    picker->setStateMachine(new QwtPickerDragPointMachine);
    picker->setRubberBandPen(GColor(CPLOTTRACKER));

    connect(picker, SIGNAL(moved(const QPoint &)), SLOT(pickerMoved(const QPoint &)));
    connect(cpintTimeValue, SIGNAL(editingFinished()), this, SLOT(cpintTimeValueEntered()));
    connect(cpintSetCPButton, SIGNAL(clicked()), this, SLOT(cpintSetCPButtonClicked()));
    if (rangemode) {
        connect(this, SIGNAL(dateRangeChanged(DateRange)), SLOT(dateRangeChanged(DateRange)));
    } else {
        connect(cComboSeason, SIGNAL(currentIndexChanged(int)), this, SLOT(seasonSelected(int)));
    }

    connect(seriesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setSeries(int)));
    //connect(mainWindow, SIGNAL(rideSelected()), this, SLOT(rideSelected()));
    connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected()));
    connect(mainWindow, SIGNAL(configChanged()), cpintPlot, SLOT(configChanged()));

    // redraw on config change -- this seems the simplest approach
    connect(mainWindow, SIGNAL(configChanged()), this, SLOT(rideSelected()));
    connect(mainWindow, SIGNAL(rideAdded(RideItem*)), this, SLOT(newRideAdded(RideItem*)));
    connect(mainWindow, SIGNAL(rideDeleted(RideItem*)), this, SLOT(newRideAdded(RideItem*)));
    connect(seasons, SIGNAL(seasonsChanged()), this, SLOT(resetSeasons()));

    connect(dateSetting, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange)));
    connect(dateSetting, SIGNAL(useThruToday()), this, SLOT(useThruToday()));
    connect(dateSetting, SIGNAL(useStandardRange()), this, SLOT(useStandardRange()));
}
//------------------------------------------------------------------------------
QWidget *FeedPropertiesDialog::createGeneralTab()
{
  QWidget *tab = new QWidget();

  QGridLayout *layoutGeneralGrid = new QGridLayout();
  QLabel *labelTitleCapt = new QLabel(tr("Title:"));
  QLabel *labelHomepageCapt = new QLabel(tr("Homepage:"));
  QLabel *labelURLCapt = new QLabel(tr("Feed URL:"));

  QHBoxLayout *layoutGeneralTitle = new QHBoxLayout();
  editTitle = new LineEdit();
  ToolButton *loadTitleButton = new ToolButton();
  loadTitleButton->setIcon(QIcon(":/images/updateFeed"));
  loadTitleButton->setIconSize(QSize(16, 16));
  loadTitleButton->setToolTip(tr("Load Title"));
  loadTitleButton->setFocusPolicy(Qt::NoFocus);

  QMenu *selectIconMenu = new QMenu();
  selectIconMenu->addAction(tr("Load Favicon"));
  selectIconMenu->addSeparator();
  selectIconMenu->addAction(tr("Select Icon..."));
  selectIconButton_ = new QToolButton(this);
  selectIconButton_->setIconSize(QSize(16, 16));
  selectIconButton_->setToolTip(tr("Select Icon"));
  selectIconButton_->setFocusPolicy(Qt::NoFocus);
  selectIconButton_->setPopupMode(QToolButton::MenuButtonPopup);
  selectIconButton_->setMenu(selectIconMenu);

  layoutGeneralTitle->addWidget(editTitle, 1);
  layoutGeneralTitle->addWidget(loadTitleButton);
  layoutGeneralTitle->addWidget(selectIconButton_);
  editURL = new LineEdit();

  disableUpdate_ = new QCheckBox(tr("Disable update"));
  disableUpdate_->setChecked(false);

  updateEnable_ = new QCheckBox(tr("Automatically update every"));
  updateInterval_ = new QSpinBox();
  updateInterval_->setEnabled(false);
  updateInterval_->setRange(1, 9999);
  connect(updateEnable_, SIGNAL(toggled(bool)),
          updateInterval_, SLOT(setEnabled(bool)));

  updateIntervalType_ = new QComboBox(this);
  updateIntervalType_->setEnabled(false);
  QStringList intervalTypeList;
  intervalTypeList << tr("seconds") << tr("minutes")  << tr("hours");
  updateIntervalType_->addItems(intervalTypeList);
  connect(updateEnable_, SIGNAL(toggled(bool)),
          updateIntervalType_, SLOT(setEnabled(bool)));

  QHBoxLayout *updateFeedsLayout = new QHBoxLayout();
  updateFeedsLayout->setMargin(0);
  updateFeedsLayout->addWidget(updateEnable_);
  updateFeedsLayout->addWidget(updateInterval_);
  updateFeedsLayout->addWidget(updateIntervalType_);
  updateFeedsLayout->addStretch();

  connect(disableUpdate_, SIGNAL(toggled(bool)),
          updateEnable_, SLOT(setDisabled(bool)));
  connect(disableUpdate_, SIGNAL(toggled(bool)),
          updateInterval_, SLOT(setDisabled(bool)));
  connect(disableUpdate_, SIGNAL(toggled(bool)),
          updateIntervalType_, SLOT(setDisabled(bool)));

  starredOn_ = new QCheckBox(tr("Starred"));
  displayOnStartup = new QCheckBox(tr("Display in new tab on startup"));
  duplicateNewsMode_ = new QCheckBox(tr("Automatically delete duplicate news"));

  QHBoxLayout *layoutGeneralHomepage = new QHBoxLayout();
  labelHomepage = new QLabel();
  labelHomepage->setOpenExternalLinks(true);
  layoutGeneralHomepage->addWidget(labelHomepageCapt);
  layoutGeneralHomepage->addWidget(labelHomepage, 1);

  layoutGeneralGrid->addWidget(labelTitleCapt, 0, 0);
  layoutGeneralGrid->addLayout(layoutGeneralTitle, 0 ,1);
  layoutGeneralGrid->addWidget(labelURLCapt, 1, 0);
  layoutGeneralGrid->addWidget(editURL, 1, 1);

  QVBoxLayout *tabLayout = new QVBoxLayout(tab);
  tabLayout->setMargin(10);
  tabLayout->setSpacing(5);
  tabLayout->addLayout(layoutGeneralGrid);
  tabLayout->addLayout(layoutGeneralHomepage);
  tabLayout->addSpacing(15);
  tabLayout->addWidget(disableUpdate_);
  tabLayout->addLayout(updateFeedsLayout);
  tabLayout->addSpacing(15);
  tabLayout->addWidget(starredOn_);
  tabLayout->addWidget(displayOnStartup);
  tabLayout->addWidget(duplicateNewsMode_);
  tabLayout->addStretch();

  connect(loadTitleButton, SIGNAL(clicked()), this, SLOT(setDefaultTitle()));
  connect(selectIconButton_, SIGNAL(clicked()),
          this, SLOT(selectIcon()));
  connect(selectIconMenu->actions().at(0), SIGNAL(triggered()),
          this, SLOT(loadDefaultIcon()));
  connect(selectIconMenu->actions().at(2), SIGNAL(triggered()),
          this, SLOT(selectIcon()));

  if (!isFeed_) {
    loadTitleButton->hide();
    selectIconButton_->hide();
    labelURLCapt->hide();
    editURL->hide();
    labelHomepageCapt->hide();
    labelHomepage->hide();
    starredOn_->hide();
    duplicateNewsMode_->hide();
  }

  return tab;
}
Exemple #3
0
void KSSLInfoDlg::setup(KSSLCertificate *cert, const QString &ip, const QString &url, const QString &cipher, const QString &cipherdesc,
                        const QString &sslversion, int usedbits, int bits, KSSLCertificate::KSSLValidation /*certState*/)
{
    // Needed to put the GUI stuff here to get the layouting right

    d->_cert = cert;

    QGridLayout *layout = new QGridLayout(4, 2, KDialog::spacingHint());

    layout->addWidget(new QLabel(i18n("Chain:"), this), 0, 0);
    d->_chain = new KComboBox(this);
    layout->addMultiCellWidget(d->_chain, 1, 1, 0, 1);
    connect(d->_chain, SIGNAL(activated(int)), this, SLOT(slotChain(int)));

    d->_chain->clear();

    if(cert->chain().isValid() && cert->chain().depth() > 1)
    {
        d->_chain->setEnabled(true);
        d->_chain->insertItem(i18n("0 - Site Certificate"));
        int cnt = 0;
        QPtrList< KSSLCertificate > cl = cert->chain().getChain();
        cl.setAutoDelete(true);
        for(KSSLCertificate *c = cl.first(); c != 0; c = cl.next())
        {
            KSSLX509Map map(c->getSubject());
            QString id;
            id = map.getValue("CN");
            if(id.length() == 0)
                id = map.getValue("O");
            if(id.length() == 0)
                id = map.getValue("OU");
            d->_chain->insertItem(QString::number(++cnt) + " - " + id);
        }
        d->_chain->setCurrentItem(0);
    }
    else
        d->_chain->setEnabled(false);

    layout->addWidget(new QLabel(i18n("Peer certificate:"), this), 2, 0);
    layout->addWidget(d->_subject = static_cast< KSSLCertBox * >(buildCertInfo(cert->getSubject())), 3, 0);
    layout->addWidget(new QLabel(i18n("Issuer:"), this), 2, 1);
    layout->addWidget(d->_issuer = static_cast< KSSLCertBox * >(buildCertInfo(cert->getIssuer())), 3, 1);
    d->m_layout->addMultiCell(layout, 1, 1, 0, 2);

    layout = new QGridLayout(11, 2, KDialog::spacingHint());
    layout->setColStretch(1, 1);
    QLabel *ipl = new QLabel(i18n("IP address:"), this);
    layout->addWidget(ipl, 0, 0);
    if(ip.isEmpty())
    {
        ipl->hide();
    }
    layout->addWidget(ipl = new QLabel(ip, this), 0, 1);
    if(ip.isEmpty())
    {
        ipl->hide();
    }
    layout->addWidget(new QLabel(i18n("URL:"), this), 1, 0);
    KSqueezedTextLabel *urlLabel = new KSqueezedTextLabel(url, this);
    layout->addWidget(urlLabel, 1, 1);
    layout->addWidget(new QLabel(i18n("Certificate state:"), this), 2, 0);

    layout->addWidget(d->_csl = new QLabel("", this), 2, 1);

    update();

    layout->addWidget(new QLabel(i18n("Valid from:"), this), 3, 0);
    layout->addWidget(d->_validFrom = new QLabel("", this), 3, 1);
    layout->addWidget(new QLabel(i18n("Valid until:"), this), 4, 0);
    layout->addWidget(d->_validUntil = new QLabel("", this), 4, 1);

    layout->addWidget(new QLabel(i18n("Serial number:"), this), 5, 0);
    layout->addWidget(d->_serialNum = new QLabel("", this), 5, 1);
    layout->addWidget(new QLabel(i18n("MD5 digest:"), this), 6, 0);
    layout->addWidget(d->_digest = new QLabel("", this), 6, 1);

    layout->addWidget(new QLabel(i18n("Cipher in use:"), this), 7, 0);
    layout->addWidget(new QLabel(cipher, this), 7, 1);
    layout->addWidget(new QLabel(i18n("Details:"), this), 8, 0);
    layout->addWidget(new QLabel(cipherdesc.simplifyWhiteSpace(), this), 8, 1);
    layout->addWidget(new QLabel(i18n("SSL version:"), this), 9, 0);
    layout->addWidget(new QLabel(sslversion, this), 9, 1);
    layout->addWidget(new QLabel(i18n("Cipher strength:"), this), 10, 0);
    layout->addWidget(new QLabel(i18n("%1 bits used of a %2 bit cipher").arg(usedbits).arg(bits), this), 10, 1);
    d->m_layout->addMultiCell(layout, 2, 2, 0, 2);

    displayCert(cert);
}
ISOSelectView::ISOSelectView(QWidget *parent) : QFrame(parent)
{
    setObjectName("ISOSelectView");
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setContentsMargins(0, 9, 0, 0);

    QLabel *m_title = new QLabel(tr("Select an ISO image file"));
    m_title->setFixedHeight(38);
    m_title->setStyleSheet("font-size: 26px;");

    QLabel *isoIcon = new QLabel(this);
    isoIcon->setObjectName("ISOIcon");
    isoIcon->setFixedSize(96, 96);
    isoIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/media-optical-96px.svg", this));

    QLabel *growIcon = new QLabel(this);
    growIcon->setObjectName("GrowIcon");
    growIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/glow.svg", this));
    growIcon->setFixedSize(220, 220);
    growIcon->hide();

    DropFrame *isoPanel = new DropFrame;
    isoPanel->setObjectName("IosPanel");
    isoPanel->setFixedSize(412, 322);

    QVBoxLayout *isoPanelLayout = new QVBoxLayout(isoPanel);
    isoPanelLayout->setMargin(0);

    m_fileLabel = new QLabel(tr("Drag an ISO image file and drop it here"));
    m_fileLabel->setObjectName("IsoFileName");
//    m_fileLabel->setFixedHeight(18);

    m_hits = new QLabel(tr("OR"));
    m_hits->setObjectName("IsoHits");
    m_hits->setFixedHeight(18);

    QLabel *spliter = new QLabel;
    spliter->setObjectName("IsoSpliter");
    spliter->setFixedSize(230, 1);

    m_fileSelect = new QLabel();
    m_fileSelect->setObjectName("IsoFileSelect");
//    m_fileSelect->setFixedHeight(15);
    m_fileSelect->setOpenExternalLinks(false);
    QString selectText = tr("Select an ISO image file");
    QString linkText = QString(s_linkTemplate).arg(selectText).arg(selectText);
    m_fileSelect->setText(linkText);

    isoPanelLayout->addSpacing(62);
    isoPanelLayout->addWidget(isoIcon, 0, Qt::AlignCenter);
    isoPanelLayout->addSpacing(5);
    isoPanelLayout->addWidget(m_fileLabel, 0, Qt::AlignCenter);
    isoPanelLayout->addSpacing(4);
    isoPanelLayout->addWidget(m_hits, 0, Qt::AlignCenter);
    isoPanelLayout->addSpacing(7);
    isoPanelLayout->addWidget(spliter, 0, Qt::AlignCenter);
    isoPanelLayout->addSpacing(12);
    isoPanelLayout->addWidget(m_fileSelect, 0, Qt::AlignCenter);
    isoPanelLayout->addStretch();

    m_nextSetp = new SuggestButton();
    m_nextSetp->setObjectName("NextStepButton");
    m_nextSetp->setText(tr("Next"));
    m_nextSetp->setDisabled(true);

    mainLayout->addWidget(m_title, 0, Qt::AlignCenter);
    mainLayout->addSpacing(24);
    mainLayout->addWidget(isoPanel, 0, Qt::AlignCenter);
    mainLayout->addStretch();
    mainLayout->addWidget(m_nextSetp, 0, Qt::AlignCenter);

    this->setStyleSheet(WidgetUtil::getQss(":/theme/light/ISOSelectView.theme"));

#ifdef Q_OS_WIN
    m_fileLabel->hide();
    spliter->hide();
    m_hits->hide();
#endif
    connect(isoPanel, &DropFrame::fileAboutAccept, this, [ = ]() {
        growIcon->show();
        auto center = isoIcon->geometry().center();
        growIcon->move(center);
        auto topleft = growIcon->mapFromGlobal(isoIcon->mapToGlobal(center));
        auto offset = 220 - 96;
        topleft.setX(topleft.x() - offset / 2);
        topleft.setY(topleft.y() - offset / 2);
        growIcon->move(topleft);
        isoPanel->setProperty("active", true);
        this->style()->unpolish(isoPanel);
        this->style()->polish(isoPanel);
    });
    connect(isoPanel, &DropFrame::fileCancel, this, [ = ]() {
        growIcon->hide();
        isoPanel->setProperty("active", false);
        this->style()->unpolish(isoPanel);
        this->style()->polish(isoPanel);
    });

    connect(m_fileSelect, &QLabel::linkActivated, this, [ = ](const QString & /*link*/) {
        QFileDialog fileDlg(this);
        fileDlg.setViewMode(QFileDialog::Detail);
        fileDlg.setFileMode(QFileDialog::ExistingFile);
        fileDlg.setDirectory(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
        fileDlg.setNameFilter("ISO (*.iso)");
        fileDlg.selectNameFilter("ISO (*.iso)");
        if (QFileDialog::Accepted == fileDlg.exec()) {
            QString text = fileDlg.selectedFiles().first();
            onFileSelected(text);
        }
    });

    connect(m_nextSetp, &SuggestButton::clicked, this, &ISOSelectView::isoFileSelected);
    connect(isoPanel, &DropFrame::fileDrop, this, &ISOSelectView::onFileSelected);

}
Exemple #5
0
int main(int argc, char **argv)
{
	Vals vals;

	/* the application */
	QApplication app(argc, argv);
	app.setApplicationName(APP_NAME);
	app.setWindowIcon(QIcon(":/icon"));
	Window window;

	/* translations */
	QTranslator qtr;
	if (qtr.load("qt_" + QLocale::system().name(), QTR_PATH))
		app.installTranslator(&qtr);

	QTranslator htr;
	if (htr.load("H4KvT_" + QLocale::system().name(), ":/"))
		app.installTranslator(&htr);

	/* display information */
	QTextEdit *text = new QTextEdit;
	text->setReadOnly(true);
	text->setLineWrapMode(QTextEdit::NoWrap);
	text->setToolTip(Window::tr("Drop any file for hashing"));
	QObject::connect(&window, &Window::idle, text, &QWidget::setEnabled);

	/* compare hash */
	QLineEdit *test = new QLineEdit;
	HexVal hexval;
	test->setValidator(&hexval);
	test->installEventFilter(&window);
	test->setToolTip(Window::tr("Compare hashes"));

	QObject::connect(test, &QLineEdit::textChanged,
		[&](const QString &newValue) { if (vals.name != "") {
			std::string hashVal = newValue.toStdString();
			std::transform(hashVal.begin(), hashVal.end(), hashVal.begin(), ::tolower);
			std::stringstream html;
			if (hashVal != "")
				html << "<style>.h" << hashVal << "{color:green}</style>";
			html << "<div style='margin-bottom:2; font-size:27px'><i><b>" << vals.name << "</b></i></div>";
			html << "<div style='margin-bottom:7; margin-left:23; font-size:13px'>" << vals.path << "</div>";
			if (!ALL(vals,"")) {
				html << "<div style='font-size:13px'><table>";
				if (vals.md5 != "")
					html << "<tr><td>md5: </td><td class='h" << vals.md5 << "'>" << vals.md5 << "</td</tr>";
				if (vals.sha1 != "")
					html << "<tr><td>sha1: </td><td class='h" << vals.sha1 << "'>" << vals.sha1 << "</td</tr>";
				if (vals.sha224 != "")
					html << "<tr><td>sha224: </td><td class='h" << vals.sha224 << "'>" << vals.sha224 << "</td</tr>";
				if (vals.sha256 != "")
					html << "<tr><td>sha256: </td><td class='h" << vals.sha256 << "'>" << vals.sha256 << "</td</tr>";
				if (vals.sha384 != "")
					html << "<tr><td>sha384: </td><td class='h" << vals.sha384 << "'>" << vals.sha384 << "</td</tr>";
				if (vals.sha512 != "")
					html << "<tr><td>sha512: </td><td class='h" << vals.sha512 << "'>" << vals.sha512 << "</td</tr>";
				html << "</table></div>";
			}
			int horizontal = text->horizontalScrollBar()->value();
			int vertical = text->verticalScrollBar()->value();
			text->setHtml(QString::fromStdString(html.str()));
			text->horizontalScrollBar()->setValue(horizontal);
			text->verticalScrollBar()->setValue(vertical);
			test->setStyleSheet(ANY(vals,hashVal) ? "color:green" : "");
		}});

	/* error messages */
	QLabel *error = new QLabel;
	error->setStyleSheet("color:red");

	/* test or error */
	QStackedWidget *stack = new QStackedWidget;
	delete stack->layout();
	stack->setLayout(new Stack);
	stack->addWidget(error);
	stack->addWidget(test);
	stack->setCurrentIndex(1);

	/* toggle test or error */
	QPushButton *hash = new QPushButton(QIcon(":/icon"), "");
	hash->setCheckable(true);
	hash->setChecked(true);
	hash->setToolTip(Window::tr("Compare hashes"));
	QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex);

	/* store method */
	QSettings settings("H4KvT", "H4KvT");

	/* more methods */
	bool more;
	try {
		settings.setValue("MoreHashingMethods", more = moreOrLess());
	} catch (...) {
		more = settings.value("MoreHashingMethods", false).toBool();
	}

	/* hashing method */
	QComboBox *meth = new QComboBox;
	meth->addItem("md5");
	meth->addItem("sha1");
	if (more) meth->addItem("sha224");
	meth->addItem("sha256");
	if (more) meth->addItem("sha384");
	meth->addItem("sha512");
	meth->setToolTip(Window::tr("Hashing method"));
	meth->setCurrentText(settings.value("HashingMethod", "md5").toString());
	QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled);

	QObject::connect(meth, &QComboBox::currentTextChanged,
		[&](const QString &text) { settings.setValue("HashingMethod", text); });

	/* toolbar */
	QHBoxLayout *pane = new QHBoxLayout;
	pane->addWidget(hash, 0, Qt::AlignLeft);
	pane->addWidget(stack);
	pane->addWidget(meth, 0, Qt::AlignRight);

	/* main layout */
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(text);
	layout->addLayout(pane);

	/* the window */
	window.centralWidget()->setLayout(layout);
	window.show();

	/* future hashing */
	QFutureWatcher<Vals> zu;
	QObject::connect(&zu, &QFutureWatcher<Vals>::finished,
		[&]() {
			Vals valsi = zu.future().result();
			window.idle(true);
			if (valsi.path == "") {
				error->setText(QString::fromStdString(valsi.name));
				hash->setChecked(false);
			} else {
				error->clear();
				vals += valsi;
				test->textChanged(test->text());
			}
		});

	QObject::connect(meth, &QComboBox::currentTextChanged,
		[&](const QString &text) { if (vals.name != "") {
			window.idle(false);
			zu.setFuture(QtConcurrent::run(&update, text, vals));
		}});

	QObject::connect(&window, &Window::fileDroped,
		[&](const QString &name, const QString &path) {
			window.idle(false);
			zu.setFuture(QtConcurrent::run(&update, meth->currentText(), Vals(name, path)));
		});

	/* hashing info */
	QGraphicsBlurEffect blur;
	blur.setBlurHints(QGraphicsBlurEffect::AnimationHint);

	QPropertyAnimation anim(&blur, "blurRadius");
	anim.setDuration(2000);
	anim.setLoopCount(-1);
	anim.setKeyValueAt(0, 0);
	anim.setKeyValueAt(0.5, 3);
	anim.setKeyValueAt(1, 0);

	QLabel *hashing = new QLabel;
	hashing->setPixmap(QPixmap(":/icon"));
	hashing->setAttribute(Qt::WA_TransparentForMouseEvents);
	hashing->setGraphicsEffect(&blur);
	hashing->hide();
	(new QHBoxLayout(text))->addWidget(hashing, 0, Qt::AlignCenter);

	QObject::connect(&blur, &QGraphicsBlurEffect::blurRadiusChanged,
		hashing, static_cast<void(QWidget::*)()>(&QWidget::update));

	QObject::connect(&window, &Window::idle,
		[&](bool idle) {
			if (idle) {
				hashing->hide();
				anim.stop();
			} else {
				hashing->show();
				anim.start();
			}
		});

	/* about app */
	QMenu about;
	QAction *action = about.addAction(QIcon(":/icon"), Window::tr("About %1").arg(APP_NAME));
	action->setMenuRole(QAction::AboutRole);
	QObject::connect(action, &QAction::triggered, &window, &Window::about);

	error->setContextMenuPolicy(Qt::NoContextMenu);
	hash->setContextMenuPolicy(Qt::NoContextMenu);
	meth->setContextMenuPolicy(Qt::NoContextMenu);
	window.setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(&window, &QWidget::customContextMenuRequested,
		[&about, &window](const QPoint &pos) { about.popup(window.mapToGlobal(pos)); });

	text->setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(text, &QWidget::customContextMenuRequested,
		[action, text](const QPoint &pos) {
			if (QMenu *m = text->createStandardContextMenu()) {
				m->insertAction(m->insertSeparator(m->actions()[0]), action);
				m->popup(text->mapToGlobal(pos));
			}
		});

	test->setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(test, &QWidget::customContextMenuRequested,
		[action, test](const QPoint &pos) {
			if (QMenu *m = test->createStandardContextMenu()) {
				m->insertAction(m->insertSeparator(m->actions()[0]), action);
				m->popup(test->mapToGlobal(pos));
			}
		});

	return app.exec();
}
Exemple #6
0
MultiQFileDialog::MultiQFileDialog(QWidget *parent, const QString &caption, const QString &directory, bool multiSelect, const QString &filter)
    : QFileDialog(parent, caption, directory, filter)
{
    this->showHidden = false;
    this->multiSelect = multiSelect;
    setOption(QFileDialog::DontUseNativeDialog, false);

    if (multiSelect)
    {
        setOption(QFileDialog::DontUseNativeDialog, true);
        le = findChild<QLineEdit*>(QString::fromUtf8("fileNameEdit"));

        QListView *l = findChild<QListView*>(QString::fromUtf8("listView"));
        if (l)
        {
            l->setSelectionMode(QListView::ExtendedSelection);
            if (le)
            {
                connect(l->selectionModel(),
                        SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
                        this,
                        SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & )));
            }
        }

        QTreeView *t = findChild<QTreeView*>();
        if (t)
        {
            t->setSelectionMode(QAbstractItemView::ExtendedSelection);
            if (le)
            {
                connect(t->selectionModel(),
                        SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
                        this,
                        SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & )));
            }
        }

        QLabel *label = findChild<QLabel*>(QString::fromUtf8("fileNameLabel"));
        if (label)
        {
            label->hide();
        }

        label = findChild<QLabel*>(QString::fromUtf8("fileTypeLabel"));
        if (label)
        {
            label->hide();
        }

        label = findChild<QLabel*>(QString::fromUtf8("lookInLabel"));
        if (label)
        {
            label->hide();
        }

        QDialogButtonBox *buttonBox = findChild<QDialogButtonBox*>(QString::fromUtf8("buttonBox"));
        if (buttonBox)
        {
            buttonBox->button(QDialogButtonBox::Open)->setText(QCoreApplication::translate("QDialogButtonBox", "&OK"));
        }

        setFileMode(QFileDialog::ExistingFiles);
        if (le)
        {
            le->setText(QCoreApplication::translate("ShellExtension", "Upload to MEGA"));
        }
    }

    QList<QWidget *> widgets = findChildren<QWidget *>();
    for (QList<QWidget *>::const_iterator it = widgets.begin(); it != widgets.end(); ++it)
    {
       (*it)->installEventFilter(this);
    }
    installEventFilter(this);
}
Exemple #7
0
GltxFrame::GltxFrame(MainWindow* main, const QString& numText, QWidget* parent)
    : QGroupBox(parent, "GltxFrame"), _main(main), _quasar(main->quasar())
{
    numberLabel = new QLabel(numText, this);
    number = new LineEdit(14, this);
    numberLabel->setBuddy(number);

    QLabel* dateLabel = new QLabel(tr("&Date:"), this);
    date = new DatePopup(this);
    dateLabel->setBuddy(date);

    QLabel* storeLabel = new QLabel(tr("Store:"), this);
    storeLookup = new StoreLookup(_main, parent);
    store = new LookupEdit(storeLookup, this);
    store->setLength(20);
    storeLabel->setBuddy(store);

    QLabel* referenceLabel = new QLabel(tr("Reference:"), this);
    reference = new LineEdit(9, this);
    referenceLabel->setBuddy(reference);

    QLabel* timeLabel = new QLabel(tr("&Time:"), this);
    time = new TimeEdit(this);
    timeLabel->setBuddy(time);

    QLabel* stationLabel = new QLabel(tr("Station:"), this);
    station = new LookupEdit(new StationLookup(_main, parent), this);
    station->setLength(20);
    stationLabel->setBuddy(station);

    QLabel* shiftLabel = new QLabel(tr("Shift:"), this);
    shift = new LookupEdit(new GltxLookup(_main, parent, DataObject::SHIFT),
			    this);
    shift->setSizeInfo(8, '9');
    shift->setFocusPolicy(ClickFocus);
    shiftLabel->setBuddy(shift);

    QLabel* employeeLabel = new QLabel(tr("Employee:"), this);
    employee = new LookupEdit(new EmployeeLookup(_main, parent), this);
    employee->setLength(20);
    employeeLabel->setBuddy(employee);

    memoLabel = new QLabel(tr("&Memo:"), this);
    memo = new LineEdit(this);
    memo->setMaxLength(40);
    memo->setMinimumWidth(memo->fontMetrics().width('x') * 40);
    memoLabel->setBuddy(memo);

    grid = new QGridLayout(this, 1, 1, frameWidth() * 2);
    grid->setSpacing(3);
    grid->setMargin(6);
    grid->setColStretch(2, 1);
    grid->addColSpacing(2, 10);
    grid->setColStretch(5, 1);
    grid->addColSpacing(5, 10);
    grid->addWidget(numberLabel, 1, 0);
    grid->addWidget(number, 1, 1);
    grid->addWidget(dateLabel, 1, 3);
    grid->addWidget(date, 1, 4);
    grid->addWidget(storeLabel, 1, 6);
    grid->addWidget(store, 1, 7);
    grid->addWidget(referenceLabel, 2, 0);
    grid->addWidget(reference, 2, 1);
    grid->addWidget(timeLabel, 2, 3);
    grid->addWidget(time, 2, 4);
    grid->addWidget(stationLabel, 2, 6);
    grid->addWidget(station, 2, 7);
    grid->addWidget(shiftLabel, 3, 3);
    grid->addWidget(shift, 3, 4);
    grid->addWidget(employeeLabel, 3, 6);
    grid->addWidget(employee, 3, 7);
    grid->addWidget(memoLabel, 9, 0);
    grid->addMultiCellWidget(memo, 9, 9, 1, 7);

    // Hide store if only one possible
    if (_quasar->storeCount() == 1) {
	storeLabel->hide();
	store->hide();
    }

    setFrameStyle(QFrame::Raised | QFrame::Panel);
    memo->setFocus();
}
Exemple #8
0
AddressBook::AddressBook(MainWindow* main)
    : ActiveList(main, "AddressBook", true)
{
    _helpSource = "address_book.html";

    // Columns for all tab
    _list->addTextColumn(tr("Name"), 30);
    _list->addTextColumn(tr("Number"), 12);
    _list->addTextColumn(tr("Phone Number"), 20);
    _list->addTextColumn(tr("Type"), 14);
    _list->setSorting(0);

    // Catch changing tabs so can disable buttons
    connect(_tabs, SIGNAL(currentChanged(QWidget*)),
	    SLOT(tabChanged(QWidget*)));

    // List for customers tab
    if (_quasar->securityCheck("CustomerMaster", "View")) {
	_customer = new ListView(_tabs);
	_tabs->addTab(_customer, tr("&Customers"));
	_customer->setAllColumnsShowFocus(true);
	_customer->setRootIsDecorated(false);
	_customer->setShowSortIndicator(true);
	_customer->addTextColumn(tr("Name"), 30);
	_customer->addTextColumn(tr("Number"), 12);
	_customer->addTextColumn(tr("Phone Number"), 20);
	_customer->addMoneyColumn(tr("Balance"));
	_customer->setSorting(0);
	connectList(_customer);
    } else {
	_customer = NULL;
    }

    // List for vendors tab
    if (_quasar->securityCheck("VendorMaster", "View")) {
	_vendor = new ListView(_tabs);
	_tabs->addTab(_vendor, tr("&Vendors"));
	_vendor->setAllColumnsShowFocus(true);
	_vendor->setRootIsDecorated(false);
	_vendor->setShowSortIndicator(true);
	_vendor->addTextColumn(tr("Name"), 30);
	_vendor->addTextColumn(tr("Number"), 12);
	_vendor->addTextColumn(tr("Phone Number"), 20);
	_vendor->addMoneyColumn(tr("Balance"));
	_vendor->setSorting(0);
	connectList(_vendor);
    } else {
	_vendor = NULL;
    }

    // List for employees tab
    if (_quasar->securityCheck("EmployeeMaster", "View")) {
	_employee = new ListView(_tabs);
	_tabs->addTab(_employee, tr("&Employees"));
	_employee->setAllColumnsShowFocus(true);
	_employee->setRootIsDecorated(false);
	_employee->setShowSortIndicator(true);
	_employee->addTextColumn(tr("Name"), 30);
	_employee->addTextColumn(tr("Number"), 12);
	_employee->addTextColumn(tr("Phone Number"), 20);
	_employee->setSorting(0);
	connectList(_employee);
    } else {
	_employee = NULL;
    }

    // List for personal tab
    if (_quasar->securityCheck("PersonalMaster", "View")) {
	_personal = new ListView(_tabs);
	_tabs->addTab(_personal, tr("&Personal"));
	_personal->setAllColumnsShowFocus(true);
	_personal->setRootIsDecorated(false);
	_personal->setShowSortIndicator(true);
	_personal->addTextColumn(tr("Name"), 30);
	_personal->addTextColumn(tr("Phone Number"), 20);
	_personal->setSorting(0);
	connectList(_personal);
    } else {
	_personal = NULL;
    }

    QLabel* nameLabel = new QLabel(tr("Name:"), _search);
    _name = new LineEdit(_search);
    _name->setLength(40);
    connect(_name, SIGNAL(returnPressed()), SLOT(slotRefresh()));

    QLabel* numberLabel = new QLabel(tr("Number:"), _search);
    _number = new LineEdit(_search);
    _number->setLength(12);
    connect(_number, SIGNAL(returnPressed()), SLOT(slotRefresh()));

    QLabel* groupLabel = new QLabel(tr("Group:"), _search);
    _groupLookup = new GroupLookup(_main, this, -1);
    _group = new LookupEdit(_groupLookup, _search);
    _group->setLength(15);
    groupLabel->setBuddy(_group);

    QLabel* storeLabel = new QLabel(tr("Store:"), _search);
    _store = new LookupEdit(new StoreLookup(main, this), _search);
    _store->setLength(30);

    QGridLayout* grid = new QGridLayout(_search);
    grid->setSpacing(3);
    grid->setMargin(3);
    grid->setColStretch(2, 1);
    grid->addWidget(nameLabel, 0, 0);
    grid->addWidget(_name, 0, 1, AlignLeft | AlignVCenter);
    grid->addWidget(numberLabel, 1, 0);
    grid->addWidget(_number, 1, 1, AlignLeft | AlignVCenter);
    grid->addWidget(groupLabel, 2, 0);
    grid->addWidget(_group, 2, 1, AlignLeft | AlignVCenter);
    grid->addWidget(storeLabel, 3, 0);
    grid->addWidget(_store, 3, 1, AlignLeft | AlignVCenter);

    if (_quasar->storeCount() == 1) {
	storeLabel->hide();
	_store->hide();
    }

    setCaption(tr("Address Book"));
    finalize(false);
    _name->setFocus();
}
Exemple #9
0
K3bDataPropertiesDialog::K3bDataPropertiesDialog( K3bDataItem* dataItem, QWidget* parent, const char* name )
  : KDialogBase( Plain, i18n("File Properties"), Ok|Cancel, Ok, parent, name, true, false )
{
  m_dataItem = dataItem;

  QLabel* labelMimeType = new QLabel( plainPage() );
  QLabel* extraInfoLabel = new QLabel( plainPage() );
  m_editName = new KLineEdit( plainPage() );
  m_labelType = new QLabel( plainPage() );
  m_labelLocation = new KCutLabel( plainPage() );
  m_labelSize = new QLabel( plainPage() );
  m_labelBlocks = new QLabel( plainPage() );
  m_labelLocalName = new KCutLabel( plainPage() );
  m_labelLocalLocation = new KCutLabel( plainPage() );


  QGridLayout* grid = new QGridLayout( plainPage() );
  grid->setSpacing( spacingHint() );
  grid->setMargin( marginHint() );

  grid->addWidget( labelMimeType, 0, 0 );
  grid->addWidget( m_editName, 0, 2 );
  QFrame* line = new QFrame( plainPage() );
  line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
  grid->addMultiCellWidget( line, 1, 1, 0, 2 );
  grid->addWidget( new QLabel( i18n("Type:"), plainPage() ), 2, 0 );
  grid->addWidget( new QLabel( i18n("Location:"), plainPage() ), 4, 0 );
  grid->addWidget( new QLabel( i18n("Size:"), plainPage() ), 5, 0 );
  grid->addWidget( new QLabel( i18n("Used blocks:"), plainPage() ), 6, 0 );
  grid->addWidget( m_labelType, 2, 2 );
  grid->addWidget( extraInfoLabel, 3, 2 );
  grid->addWidget( m_labelLocation, 4, 2 );
  grid->addWidget( m_labelSize, 5, 2 );
  grid->addWidget( m_labelBlocks, 6, 2 );
  line = new QFrame( plainPage() );
  line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
  grid->addMultiCellWidget( line, 7, 7, 0, 2 );
  QLabel* label1 = new QLabel( i18n("Local name:"), plainPage() );
  grid->addWidget(  label1, 8, 0 );
  QLabel* label2 = new QLabel( i18n("Local location:"), plainPage() );
  grid->addWidget( label2, 9, 0 );
  grid->addWidget( m_labelLocalName, 8, 2 );
  grid->addWidget( m_labelLocalLocation, 9, 2 );

  grid->addColSpacing( 1, 50 );
  grid->setColStretch( 2, 1 );



  if( K3bFileItem* fileItem = dynamic_cast<K3bFileItem*>(dataItem) ) {
    KFileItem kFileItem( KFileItem::Unknown, KFileItem::Unknown, KURL::fromPathOrURL(fileItem->localPath()) );
    labelMimeType->setPixmap( kFileItem.pixmap(KIcon::SizeLarge) );
    if( fileItem->isSymLink() )
      m_labelType->setText( i18n("Link to %1").arg(kFileItem.mimeComment()) );
    else
      m_labelType->setText( kFileItem.mimeComment() );
    m_labelLocalName->setText( kFileItem.name() );
    QString localLocation = kFileItem.url().path(-1);
    localLocation.truncate( localLocation.findRev('/') );
    m_labelLocalLocation->setText( localLocation );
    m_labelSize->setText( KIO::convertSize(dataItem->size()) );
  }
  else if( K3bDirItem* dirItem = dynamic_cast<K3bDirItem*>(dataItem) ) {
    labelMimeType->setPixmap( KMimeType::pixmapForURL( KURL( "/" )) );
    m_labelType->setText( i18n("Directory") );
    label1->hide();
    label2->hide();
    m_labelLocalName->hide();
    m_labelLocalLocation->hide();
    line->hide();
    m_labelSize->setText( KIO::convertSize(dataItem->size()) + "\n(" +
			  i18n("in 1 file", "in %n files", dirItem->numFiles()) + " " +
			  i18n("and 1 directory", "and %n directories", dirItem->numDirs()) + ")" );
  }
  else {
    labelMimeType->setPixmap( DesktopIcon("unknown", KIcon::SizeLarge) );
    m_labelType->setText( i18n("Special file") );
    m_labelLocalName->hide();
    m_labelLocalLocation->hide();
    label1->hide();
    label2->hide();
    line->hide();
    m_labelSize->setText( KIO::convertSize(dataItem->size()) );
  }

  m_editName->setText( dataItem->k3bName() );
  m_labelBlocks->setText( QString::number(dataItem->blocks().lba()) );

  QString location = "/" + dataItem->k3bPath();
  if( location[location.length()-1] == '/' )
    location.truncate( location.length()-1 );
  location.truncate( location.findRev('/') );
  if( location.isEmpty() )
    location = "/";
  m_labelLocation->setText( location );
  extraInfoLabel->setText( QString( "(%1)" ).arg(dataItem->extraInfo()) );
  if( dataItem->extraInfo().isEmpty() )
    extraInfoLabel->hide();

  // OPTIONS
  // /////////////////////////////////////////////////
  QTabWidget* optionTab = new QTabWidget( plainPage() );
  line = new QFrame( plainPage() );
  line->setFrameStyle( QFrame::HLine | QFrame::Sunken );

  grid->addMultiCellWidget( line, 10, 10, 0, 2 );
  grid->addMultiCellWidget( optionTab, 12, 12, 0, 2 );
  grid->setRowStretch( 11, 1 );

  QWidget* hideBox = new QWidget( optionTab );
  QGridLayout* hideBoxGrid = new QGridLayout( hideBox );
  hideBoxGrid->setSpacing( spacingHint() );
  hideBoxGrid->setMargin( marginHint() );
  m_checkHideOnRockRidge = new QCheckBox( i18n("Hide on Rockridge"), hideBox );
  m_checkHideOnJoliet = new QCheckBox( i18n("Hide on Joliet"), hideBox );
  hideBoxGrid->addWidget( m_checkHideOnRockRidge, 0, 0 );
  hideBoxGrid->addWidget( m_checkHideOnJoliet, 1, 0 );
  hideBoxGrid->setRowStretch( 2, 1 );
//   grid->addMultiCellWidget( m_checkHideOnRockRidge, 10, 10, 0, 2 );
//   grid->addMultiCellWidget( m_checkHideOnJoliet, 11, 11, 0, 2 );

  QWidget* sortingBox = new QWidget( optionTab );
  QGridLayout* sortingBoxGrid = new QGridLayout( sortingBox );
  sortingBoxGrid->setSpacing( spacingHint() );
  sortingBoxGrid->setMargin( marginHint() );
  m_editSortWeight = new KLineEdit( sortingBox );
  m_editSortWeight->setValidator( new QIntValidator( -2147483647, 2147483647, m_editSortWeight ) );
  m_editSortWeight->setAlignment( Qt::AlignRight );
  sortingBoxGrid->addWidget( new QLabel( i18n("Sort weight:"), sortingBox ), 0, 0 );
  sortingBoxGrid->addWidget( m_editSortWeight, 0, 1 );
  sortingBoxGrid->setColStretch( 1, 1 );
  sortingBoxGrid->setRowStretch( 1, 1 );

  optionTab->addTab( hideBox, i18n("Settings") );
  optionTab->addTab( sortingBox, i18n("Advanced") );


  m_checkHideOnJoliet->setChecked( dataItem->hideOnJoliet() );
  m_checkHideOnRockRidge->setChecked( dataItem->hideOnRockRidge() );
  m_editSortWeight->setText( QString::number(dataItem->sortWeight()) );

  // if the parent is hidden the value cannot be changed (see K3bDataItem::setHide...)
  if( dataItem->parent() ) {
    m_checkHideOnRockRidge->setDisabled( dataItem->parent()->hideOnRockRidge() );
    m_checkHideOnJoliet->setDisabled( dataItem->parent()->hideOnJoliet() );
  }

  if( !dataItem->isHideable() ) {
    m_checkHideOnJoliet->setDisabled(true);
    m_checkHideOnRockRidge->setDisabled(true);
    //    line->hide();
  }

  QToolTip::add( m_checkHideOnRockRidge, i18n("Hide this file in the RockRidge filesystem") );
  QToolTip::add( m_checkHideOnJoliet, i18n("Hide this file in the Joliet filesystem") );
  QToolTip::add( m_editSortWeight, i18n("Modify the physical sorting") );
  QWhatsThis::add( m_checkHideOnRockRidge, i18n("<p>If this option is checked, the file or directory "
						"(and its entire contents) will be hidden on the "
						"ISO9660 and RockRidge filesystem.</p>"
						"<p>This is useful, for example, for having different README "
						"files for RockRidge and Joliet, which can be managed "
						"by hiding README.joliet on RockRidge and README.rr "
						"on the Joliet filesystem.</p>") );
  QWhatsThis::add( m_checkHideOnJoliet, i18n("<p>If this option is checked, the file or directory "
					     "(and its entire contents) will be hidden on the "
					     "Joliet filesystem.</p>"
					     "<p>This is useful, for example, for having different README "
					     "files for RockRidge and Joliet, which can be managed "
					     "by hiding README.joliet on RockRidge and README.rr "
					     "on the Joliet filesystem.</p>") );
  QWhatsThis::add( m_editSortWeight, i18n("<p>This value modifies the physical sort order of the files "
					  "in the ISO9660 filesystem. A higher weighting means that the "
					  "file will be located closer to the beginning of the image "
					  "(and the disk)."
					  "<p>This option is useful in order to optimize the data layout "
					  "on a CD/DVD."
					  "<p><b>Caution:</b> This does not sort the order of the file "
					  "names that appear in the ISO9660 directory."
					  "It sorts the order in which the file data is "
					  "written to the image.") );

  m_editName->setValidator( K3bValidators::iso9660Validator( false, this ) );
  m_editName->setReadOnly( !dataItem->isRenameable() );
  m_editName->setFocus();
}
Exemple #10
0
PopupMessage::PopupMessage( QWidget *parent, QWidget *anchor, int timeout)
                : OverlayWidget( parent, anchor)
                , m_anchor( anchor )
                , m_parent( parent )
                , m_maskEffect( Slide )
                , m_dissolveSize( 0 )
                , m_dissolveDelta( -1 )
                , m_offset( 0 )
                , m_counter( 0 )
                , m_stage( 1 )
                , m_timeout( timeout )
                , m_showCounter( true )
{
    setFrameStyle( QFrame::Panel | QFrame::Raised );
    setFrameShape( QFrame::StyledPanel );
//     overrideWindowFlags( Qt::WX11BypassWM );

    QHBoxLayout *hbox;
    QLabel *label;
    QLabel *alabel;
    //KActiveLabel *alabel;

	m_layout = new QVBoxLayout( this );//, 9 /*margin*/, 6 /*spacing*/ );
	m_layout->setMargin(9);
	m_layout->setSpacing(6);

	hbox = new QHBoxLayout; //( m_layout, 12 );
	hbox->setMargin(12);
	
	m_layout->addLayout(hbox);

    hbox->addWidget( m_countdownFrame = new QFrame( this ));//, "counterVisual" ) );
    m_countdownFrame->setObjectName( "counterVisual" );
    m_countdownFrame->setFixedWidth( fontMetrics().width( "X" ) );
    m_countdownFrame->setFrameStyle( QFrame::Plain | QFrame::Box );
    QPalette tmp_palette;
    tmp_palette.setColor(m_countdownFrame->foregroundRole(), palette().color(QPalette::Window).dark());
    m_countdownFrame->setPalette(tmp_palette);
//     m_countdownFrame->setPaletteForegroundColor( paletteBackgroundColor().dark() );

    label = new QLabel( this );//, "image" );
    label->setObjectName("image");
    hbox->addWidget( label );
    label->hide();

    alabel = new QLabel( "Details of the tasks: ", this );//, "label");
    alabel->setObjectName("label");
    //alabel = new KActiveLabel( this, "label" );
    //alabel->setTextFormat( Qt::RichText );
    alabel->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );

    hbox->addWidget( alabel );

	hbox = new QHBoxLayout;
	
	m_layout->addLayout(hbox);

    hbox->addItem( new QSpacerItem( 4, 4, QSizePolicy::Expanding, QSizePolicy::Preferred ) );
    //FIXME: add icon
    QPushButton * tmp_button = new QPushButton( "Close", this );
    tmp_button->setObjectName( "closeButton" );
    hbox->addWidget( tmp_button );//, "closeButton" ) );

    connect( findChild<QPushButton *>( "closeButton" ), SIGNAL(clicked()), SLOT(close()) );
}
void TrussPropertyTabWidget::initLoadTab ()
{
    QFrame* parentFrame = new QFrame;
    nodesNumbLabel = new QLabel( tr( "Total nodes: " ), parentFrame );
    loadedNodesLabel = new QLabel( tr( "Nodes loaded: " ), parentFrame );
    nodesNumbLabel->hide();
    loadedNodesLabel->hide();
    loadTable = new LoadTable( parentFrame );
    TableHeader *horHeader = new TableHeader( Qt::Horizontal ),
                *vertHeader = new TableHeader( Qt::Vertical );
    loadTable->setHorizontalHeader( horHeader );
    loadTable->setVerticalHeader( vertHeader );

    LoadTableDelegate* delegate = new LoadTableDelegate;
    loadTable->setItemDelegate( delegate );

    connect( delegate, SIGNAL(cellWasChanged(int, int)),
                       SLOT(updateTrussLoad(int, int)) );

    QGroupBox* loadCaseGroupBox =
            new QGroupBox( tr( "Load cases" ), parentFrame );
    QLabel* loadCaseNumb =
        new QLabel( tr( "Current: " ), loadCaseGroupBox );
    loadCaseNumb->hide();
    loadCaseComboBox = new QComboBox( loadCaseGroupBox );
    createLoadCaseBtn = new QPushButton( loadCaseGroupBox );
    createLoadCaseBtn->setIcon( QIcon( Global::imagesPath() + "/plus.png" ) );
    createLoadCaseBtn->setFixedSize( QSize( 22, 22 ) );
    createLoadCaseBtn->setEnabled( false );
    removeLoadCaseBtn = new QPushButton( loadCaseGroupBox );
    removeLoadCaseBtn->setIcon( QIcon( Global::imagesPath() + "/minus.png" ) );
    removeLoadCaseBtn->setFixedSize( QSize( 22, 22 ) );
    removeLoadCaseBtn->setEnabled( false );

    connect ( createLoadCaseBtn, SIGNAL(pressed()),
                                 SLOT(addLoadCase()) );
    connect ( removeLoadCaseBtn, SIGNAL(pressed()),
                                 SLOT(removeLoadCase()) );
    // init layout managers
    QVBoxLayout* parentLayout = new QVBoxLayout( parentFrame );
    QHBoxLayout* topLayout = new QHBoxLayout;
    QVBoxLayout* tableLayout = new QVBoxLayout;
    QHBoxLayout* loadCaseLayout = new QHBoxLayout( loadCaseGroupBox );
    parentLayout->addLayout( topLayout );
    parentLayout->addLayout( tableLayout );
    topLayout->addWidget( nodesNumbLabel );
    topLayout->addWidget( loadedNodesLabel );
    tableLayout->addWidget( loadTable );
    parentLayout->addWidget( loadCaseGroupBox );
    loadCaseLayout->addWidget( loadCaseNumb );
    loadCaseLayout->addWidget( loadCaseComboBox );
    loadCaseLayout->addWidget( createLoadCaseBtn);
    loadCaseLayout->addWidget( removeLoadCaseBtn );
    topLayout->setMargin( 5 );
    topLayout->setSpacing( 5 );
    tableLayout->setMargin( 1 );
    tableLayout->setSpacing( 1 );
    loadCaseLayout->setMargin( 6 );
    loadCaseLayout->setSpacing( 5 );
    parentLayout->setMargin( 1 );
    parentLayout->setSpacing( 1 );

    // init load table
    loadTable->setColumnCount( 2 );
    loadTable->setSelectionMode( QAbstractItemView::NoSelection );
    //TableHeader *horHeader = loadTable->horizontalHeader(),
    //            *vertHeader = loadTable->verticalHeader();
    horHeader->setClickable( false );
    horHeader->setResizeMode( QHeaderView::Custom );
    vertHeader->setDefaultSectionSize( Global::tableRowHeight );
    vertHeader->setClickable( false );
    vertHeader->setResizeMode( QHeaderView::Custom );
    vertHeader->setDefaultAlignment( Qt::AlignRight | Qt::AlignVCenter );
    loadTable->setShowGrid( true );

    QStringList headerList;
    headerList << tr("Froce by X") << tr("Force by Y");
    loadTable->setHorizontalHeaderLabels( headerList );
    loadTable->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
    loadTable->hide();

    addTab( parentFrame, "Loads" );
}
void BuildingComponentDialogCentralWidget::createLayout()
{
  bool isConnected = false;

  QLabel * label = new QLabel("Sort by:");
  label->hide(); // TODO remove this hack when we have sorts to do

  QComboBox * comboBox = new QComboBox(this);
  comboBox->hide(); // TODO remove this hack when we have sorts to do

  isConnected = connect(comboBox, SIGNAL(currentIndexChanged(const QString &)),
                        this, SLOT(comboBoxIndexChanged(const QString &)));
  OS_ASSERT(isConnected);

  QPushButton * upperPushButton = new QPushButton("Check All");
  isConnected = connect(upperPushButton, SIGNAL(clicked()),
                        this, SLOT(upperPushButtonClicked()));
  OS_ASSERT(isConnected);

  QHBoxLayout * upperLayout = new QHBoxLayout();
  upperLayout->addWidget(label);
  upperLayout->addWidget(comboBox);
  upperLayout->addStretch();
  upperLayout->addWidget(upperPushButton);

  m_collapsibleComponentList = new CollapsibleComponentList();

  isConnected = connect(m_collapsibleComponentList, SIGNAL(headerClicked(bool)),
                        this, SIGNAL(headerClicked(bool)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(headerClicked(bool)),
                        this, SLOT(on_headerClicked(bool)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(componentClicked(bool)),
                        this, SIGNAL(componentClicked(bool)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(componentClicked(bool)),
                        this, SLOT(on_componentClicked(bool)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(collapsibleComponentClicked(bool)),
                        this, SIGNAL(collapsibleComponentClicked(bool)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(collapsibleComponentClicked(bool)),
                        this, SLOT(on_collapsibleComponentClicked(bool)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(getComponentsByPage(int)),
                        this, SIGNAL(getComponentsByPage(int)));
  OS_ASSERT(isConnected);

  isConnected = connect(m_collapsibleComponentList, SIGNAL(getComponentsByPage(int)),
                        this, SLOT(on_getComponentsByPage(int)));
  OS_ASSERT(isConnected);

  //*******************************************************************
  // Hack code to be removed (TODO)
  m_componentList = new ComponentList();  // TODO refactor and remove

  CollapsibleComponentHeader * collapsibleComponentHeader = NULL;
  collapsibleComponentHeader = new CollapsibleComponentHeader("Constructions",100,5);

  CollapsibleComponent * collapsibleComponent = NULL;
  collapsibleComponent = new CollapsibleComponent(collapsibleComponentHeader,m_componentList);

  m_collapsibleComponentList->addCollapsibleComponent(collapsibleComponent);
  //*******************************************************************
  
  m_progressBar = new QProgressBar(this);
  m_progressBar->setVisible(false);

  QPushButton * lowerPushButton = new QPushButton("Download");
  isConnected = connect(lowerPushButton, SIGNAL(clicked()),
                        this, SLOT(lowerPushButtonClicked()));
  OS_ASSERT(isConnected);

  QHBoxLayout * lowerLayout = new QHBoxLayout();
  lowerLayout->addStretch();
  lowerLayout->addWidget(m_progressBar);
  lowerLayout->addWidget(lowerPushButton);

  QVBoxLayout * mainLayout = new QVBoxLayout();
  mainLayout->addLayout(upperLayout);

  mainLayout->addWidget(m_collapsibleComponentList,0,Qt::AlignTop);
  mainLayout->addLayout(lowerLayout);
  setLayout(mainLayout);
}