Example #1
0
void addTab(std::string tabName, ImageStorage* imgstore, Ui::MainWindow *ui)
{
	/*ui->processBtn->setEnabled(true);
	ui->previousBtn->setEnabled(true);*/

	QWidget *tab = new QWidget();
	QString qname = QString::fromStdString(tabName);
	tab->setObjectName(qname);
	QHBoxLayout *horizontalLayout = new QHBoxLayout(tab);
	horizontalLayout->setSpacing(6);
	horizontalLayout->setContentsMargins(11, 11, 11, 11);
	horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
	QScrollArea * scrollArea = new QScrollArea(tab);
	scrollArea->setObjectName(QStringLiteral("scrollArea"));
	scrollArea->setWidgetResizable(true);
	QWidget * scrollAreaWidgetContents = new QWidget();
	scrollAreaWidgetContents->setObjectName(QStringLiteral("scrollAreaWidgetContents"));
	scrollAreaWidgetContents->setGeometry(QRect(0, 0, 492, 447));
	QHBoxLayout* horizontalLayout_13 = new QHBoxLayout(scrollAreaWidgetContents);
	horizontalLayout->setSpacing(6);
	horizontalLayout_13->setContentsMargins(11, 11, 11, 11);
	horizontalLayout_13->setObjectName(QStringLiteral("horizontalLayout_13"));
	QLabel* label = new QLabel(scrollAreaWidgetContents);
	std::string stmp = tabName;
	stmp.append("_label");
	QString qname2 = QString::fromStdString(stmp);
	label->setObjectName(qname2);
	QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Expanding);
	sizePolicy2.setHorizontalStretch(0);
	sizePolicy2.setVerticalStretch(0);
	sizePolicy2.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
	label->setSizePolicy(sizePolicy2);

	horizontalLayout_13->addWidget(label);
	scrollArea->setWidget(scrollAreaWidgetContents);
	horizontalLayout->addWidget(scrollArea);
	ui->imageTab->addTab(tab, QString());

	std::string tmp1 = tabName.c_str();
	const char* tmp2 = tmp1.c_str();
	ui->imageTab->setTabText(ui->imageTab->indexOf(tab), QApplication::translate("MainWindow", tmp2, 0));
	ui->imageTab->setCurrentIndex(ui->imageTab->indexOf(tab));


	//-------------------------

	//---------------------
	//display image

	cv::Mat image = std::get<1>(imgstore->getCurrent()->second);  
	QImage img;  
	if(image.channels() == 3)    // RGB image  
	{  
		//cvtColor(image, image, CV_BGR2RGB);  
		img = QImage((const uchar*)(image.data),  //(const unsigned char*)  
			image.cols, image.rows,  
			image.cols*image.channels(),
			QImage::Format_RGB888);  
	}else                     // gray image  
	{  
		img = QImage((const uchar*)(image.data),  
			image.cols, image.rows,  
			image.cols*image.channels(),
			QImage::Format_Indexed8);  
	}  

	if (!img.isNull())
	{
		label->setPixmap(QPixmap::fromImage(img));  
		label->resize(label->pixmap()->size());  
		label->setAlignment(Qt::AlignCenter);
		label->show();
	}
	else
	{
		ASSERT(0);
	}
	  

	//---------------------
}
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent )
    : QWidget( parent )
    , ui( new Ui::ArtistInfoWidget )
    , m_artist( artist )
{
    QWidget* widget = new QWidget;
    ui->setupUi( widget );

    artist->loadStats();
    connect( artist.data(), SIGNAL( statsLoaded() ), SLOT( onArtistStatsLoaded() ) );

    ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );
    ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) );
    ui->lineAbove2->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) );
    ui->lineBelow2->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );

    QHBoxLayout* l = new QHBoxLayout( ui->statsWidget );
    m_playStatsGauge = new StatsGauge( ui->statsWidget );
    m_playStatsGauge->setText( tr( "YOUR ARTIST RANK" ) );
    m_playStatsGauge->setInvertedAppearance( true );

    l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
    l->addWidget( m_playStatsGauge );
    l->addSpacerItem( new QSpacerItem( 0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ) );
    ui->statsWidget->setLayout( l );
    TomahawkUtils::unmarginLayout( l );

    m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, QSize( 48, 48 ) );
    ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Grid, ui->cover->size() ) );
    ui->cover->setShowText( false );

    {
        m_relatedModel = new PlayableModel( ui->relatedArtists );
        ui->relatedArtists->setPlayableModel( m_relatedModel );
        ui->relatedArtists->proxyModel()->sort( -1 );
        ui->relatedArtists->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) );

        ui->relatedArtists->setAutoFitItems( true );
    /*    ui->relatedArtists->setWrapping( false );
        ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );*/
        ui->relatedArtists->delegate()->setItemSize( QSize( 170, 170 ) );

        TomahawkStyle::stylePageFrame( ui->relatedArtists );
        TomahawkStyle::stylePageFrame( ui->artistFrame );
        TomahawkStyle::styleScrollBar( ui->relatedArtists->verticalScrollBar() );
    }

    {
        ui->albums->setAutoResize( true );
        ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    /*    ui->albums->setWrapping( false );
        ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );*/
        ui->albums->delegate()->setItemSize( QSize( 170, 170 ) );
        ui->albums->proxyModel()->setHideDupeItems( true );

        m_albumsModel = new PlayableModel( ui->albums );
        ui->albums->setPlayableModel( m_albumsModel );
        ui->albums->proxyModel()->sort( -1 );
        ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) );

        ui->albums->setStyleSheet( QString( "QListView { background-color: %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) );
        TomahawkStyle::stylePageFrame( ui->albumFrame );
        TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() );
    }

    {
        m_topHitsModel = new PlaylistModel( ui->topHits );
        AlbumItemDelegate* del = new AlbumItemDelegate( ui->topHits, ui->topHits->proxyModel() );
        ui->topHits->setPlaylistItemDelegate( del );
        ui->topHits->proxyModel()->setStyle( PlayableProxyModel::Short );
        ui->topHits->setPlayableModel( m_topHitsModel );
        ui->topHits->setSortingEnabled( false );
        ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) );
        ui->topHits->setAutoResize( true );
        ui->topHits->setAlternatingRowColors( false );

        QPalette p = ui->topHits->palette();
        p.setColor( QPalette::Text, TomahawkStyle::PAGE_TRACKLIST_TRACK_SOLVED );
        p.setColor( QPalette::BrightText, TomahawkStyle::PAGE_TRACKLIST_TRACK_UNRESOLVED );
        p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_TRACKLIST_NUMBER );
        p.setColor( QPalette::Highlight, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT );
        p.setColor( QPalette::HighlightedText, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT_TEXT );

        ui->topHits->setPalette( p );
        TomahawkStyle::stylePageFrame( ui->topHits );
        TomahawkStyle::stylePageFrame( ui->trackFrame );
    }

    {
        QFont f = ui->biography->font();
        f.setFamily( "Titillium Web" );

        QPalette p = ui->biography->palette();
        p.setColor( QPalette::Text, TomahawkStyle::HEADER_TEXT );

        ui->biography->setFont( f );
        ui->biography->setPalette( p );
        ui->biography->setOpenLinks( false );
        ui->biography->setOpenExternalLinks( true );

        ui->biography->document()->setDefaultStyleSheet( QString( "a { text-decoration: none; font-weight: bold; color: %1; }" ).arg( TomahawkStyle::HEADER_LINK.name() ) );
        TomahawkStyle::stylePageFrame( ui->biography );
        TomahawkStyle::styleScrollBar( ui->biography->verticalScrollBar() );

        connect( ui->biography, SIGNAL( anchorClicked( QUrl ) ), SLOT( onBiographyLinkClicked( QUrl ) ) );
    }

    {
        QFont f = ui->artistLabel->font();
        f.setFamily( "Titillium Web" );

        QPalette p = ui->artistLabel->palette();
        p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_LABEL );

        ui->artistLabel->setFont( f );
        ui->artistLabel->setPalette( p );
    }

    {
        QFont f = ui->label->font();
        f.setFamily( "Pathway Gothic One" );

        QPalette p = ui->label->palette();
        p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_CAPTION );

        ui->label->setFont( f );
        ui->label_2->setFont( f );
        ui->label->setPalette( p );
        ui->label_2->setPalette( p );
    }

    {
        QFont f = ui->albumLabel->font();
        f.setFamily( "Pathway Gothic One" );

        QPalette p = ui->albumLabel->palette();
        p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT );

        ui->albumLabel->setFont( f );
        ui->albumLabel->setPalette( p );
    }

    {
        QScrollArea* area = new QScrollArea();
        area->setWidgetResizable( true );
        area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
        area->setWidget( widget );

        QPalette pal = palette();
        pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND );
        area->setPalette( pal );
        area->setAutoFillBackground( true );
        area->setFrameShape( QFrame::NoFrame );
        area->setAttribute( Qt::WA_MacShowFocusRect, 0 );

        QVBoxLayout* layout = new QVBoxLayout();
        layout->addWidget( area );
        setLayout( layout );
        TomahawkUtils::unmarginLayout( layout );
    }

    {
        QPalette pal = palette();
        pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND );
        ui->widget->setPalette( pal );
        ui->widget->setAutoFillBackground( true );
    }

    MetaPlaylistInterface* mpl = new MetaPlaylistInterface();
    mpl->addChildInterface( ui->relatedArtists->playlistInterface() );
    mpl->addChildInterface( ui->topHits->playlistInterface() );
    mpl->addChildInterface( ui->albums->playlistInterface() );
    m_plInterface = playlistinterface_ptr( mpl );

    load( artist );
}
HelpPanel::HelpPanel(QWidget * parent)
    : QFrame(parent)
{
    class PrivateSubscriberClose
        : public QObject
        , private SubscribablePushButton::Subscriber
    {

    public:

        ~PrivateSubscriberClose()
        {
        }

        PrivateSubscriberClose(SubscribablePushButton * pushButton)
            : QObject(pushButton)
            , SubscribablePushButton::Subscriber(pushButton)
        {
        }

    private:

        void clicked(bool checked)
        {
            MainWindow::instance().showFrame(MainWindow::MainFrameIndex);
        }
    };

    QBoxLayout * topLayout = new QVBoxLayout();
    setLayout(topLayout);

    QFormLayout * formLayout = new QFormLayout();

    QFrame * buttonsWidget = new QFrame(NULL);
    buttonsWidget->setLayout(formLayout);
    buttonsWidget->setObjectName("helpButtonsWidget");
    buttonsWidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));

    SubscribablePushButton * moveShipButton = new SubscribablePushButton(NULL, tr("M"));
    moveShipButton->setObjectName("move");
    SubscribablePushButton * colonizeButton = new SubscribablePushButton(NULL, tr("C"));
    colonizeButton->setObjectName("colonize");
    SubscribablePushButton * loadButton = new SubscribablePushButton(NULL, tr("L"));
    loadButton->setObjectName("load");
    SubscribablePushButton * unloadButton = new SubscribablePushButton(NULL, tr("U"));
    unloadButton->setObjectName("unload");
    SubscribablePushButton * buildShipButton = new SubscribablePushButton(NULL, tr("B.."));
    buildShipButton->setObjectName("build");
    SubscribablePushButton * nextTurnButton = new SubscribablePushButton(NULL, tr("T"));
    nextTurnButton->setObjectName("turn");
    SubscribablePushButton * shipDesignButton = new SubscribablePushButton(NULL, tr("D.."));
    shipDesignButton->setObjectName("design");
    SubscribablePushButton * researchButton = new SubscribablePushButton(NULL, tr("R.."));
    researchButton->setObjectName("research");
    SubscribablePushButton * newButton = new SubscribablePushButton(NULL, tr("N.."));
    newButton->setObjectName("new");
    SubscribablePushButton * openButton = new SubscribablePushButton(NULL, tr("O.."));
    openButton->setObjectName("open");
    SubscribablePushButton * saveButton = new SubscribablePushButton(NULL, tr("S.."));
    saveButton->setObjectName("save");
    SubscribablePushButton * quitButton = new SubscribablePushButton(NULL, tr("Q"));
    quitButton->setObjectName("quit");
    SubscribablePushButton * helpButton = new SubscribablePushButton(NULL, tr("H.."));
    helpButton->setObjectName("help");
    SubscribablePushButton * setupButton = new SubscribablePushButton(NULL, tr("S.."));
    setupButton->setObjectName("setup");
    SubscribablePushButton * flagButton = new SubscribablePushButton(NULL, tr("F"));
    flagButton->setObjectName("flag");

    formLayout->addRow(newButton, new QLabel("Start a new game."));
    formLayout->addRow(openButton, new QLabel("Open a saved game."));
    formLayout->addRow(saveButton, new QLabel("Save current game."));
    formLayout->addRow(quitButton, new QLabel("Quit the program."));
    formLayout->addRow(helpButton, new QLabel("This help panel."));
    formLayout->addRow(setupButton, new QLabel("Setup panel."));
    formLayout->addRow(flagButton, new QLabel("Center map on your home system."));
    formLayout->addRow(moveShipButton, new QLabel("Move selected ship."));
    formLayout->addRow(loadButton, new QLabel("Load population from planet to selected ship."));
    formLayout->addRow(unloadButton, new QLabel("Unload population from selected ship to planet."));
    formLayout->addRow(colonizeButton, new QLabel("Order selected ship to colonize planet."));
    formLayout->addRow(buildShipButton, new QLabel("Create a build order for an existing ship design."));
    formLayout->addRow(shipDesignButton, new QLabel("Create a new ship design."));
    formLayout->addRow(researchButton, new QLabel("Research new technologies."));
    formLayout->addRow(nextTurnButton, new QLabel("Advance time by one month."));

    QScrollArea * scrollArea = new QScrollArea();
    scrollArea->setWidget(buttonsWidget);
    scrollArea->setWidgetResizable(true);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setObjectName("helpButtonsScrollArea");
    topLayout->addWidget(scrollArea);
    QsKineticScroller * kineticScroller = new QsKineticScroller(scrollArea);
    kineticScroller->enableKineticScrollFor(scrollArea);

    QBoxLayout * buttonLayout = new QHBoxLayout();
    topLayout->addItem(buttonLayout);
    SubscribablePushButton * closeButton = new SubscribablePushButton(this, tr("Close"));
    closeButton->setObjectName("closeButton");
    new PrivateSubscriberClose(closeButton);
    buttonLayout->addStretch();   
    buttonLayout->addWidget(closeButton);   
}
Example #4
0
WindowMain::WindowMain(QWidget *parent)
	: QMainWindow(parent)
{
	importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this);
	nam = new QNetworkAccessManager(this);
	
	checkBoxLayout = new QVBoxLayout;
	
	QWidget *checkboxFrame = new QWidget;
	checkboxFrame->setLayout(checkBoxLayout);
	
	QScrollArea *checkboxArea = new QScrollArea;
	checkboxArea->setWidget(checkboxFrame);
	checkboxArea->setWidgetResizable(true);
	
	checkAllButton = new QPushButton(tr("&Check all"));
	connect(checkAllButton, SIGNAL(clicked()), this, SLOT(actCheckAll()));
	uncheckAllButton = new QPushButton(tr("&Uncheck all"));
	connect(uncheckAllButton, SIGNAL(clicked()), this, SLOT(actUncheckAll()));
	
	QHBoxLayout *checkAllButtonLayout = new QHBoxLayout;
	checkAllButtonLayout->addWidget(checkAllButton);
	checkAllButtonLayout->addWidget(uncheckAllButton);
	
	startButton = new QPushButton(tr("&Start download"));
	connect(startButton, SIGNAL(clicked()), this, SLOT(actStart()));
	
	QVBoxLayout *settingsLayout = new QVBoxLayout;
	settingsLayout->addWidget(checkboxArea);
	settingsLayout->addLayout(checkAllButtonLayout);
	settingsLayout->addWidget(startButton);
	
	totalLabel = new QLabel(tr("Total progress:"));
	totalProgressBar = new QProgressBar;
	nextSetLabel1 = new QLabel(tr("Current file:"));
	nextSetLabel2 = new QLabel;
	fileLabel = new QLabel(tr("Progress:"));
	fileProgressBar = new QProgressBar;
	
	messageLog = new QTextEdit;
	messageLog->setReadOnly(true);
	
	QGridLayout *grid = new QGridLayout;
	grid->addWidget(totalLabel, 0, 0);
	grid->addWidget(totalProgressBar, 0, 1);
	grid->addWidget(nextSetLabel1, 1, 0);
	grid->addWidget(nextSetLabel2, 1, 1);
	grid->addWidget(fileLabel, 2, 0);
	grid->addWidget(fileProgressBar, 2, 1);
	grid->addWidget(messageLog, 3, 0, 1, 2);
	
	QHBoxLayout *mainLayout = new QHBoxLayout;
	mainLayout->addLayout(settingsLayout, 6);
	mainLayout->addSpacing(10);
	mainLayout->addLayout(grid, 10);
	
	QWidget *centralWidget = new QWidget;
	centralWidget->setLayout(mainLayout);
	setCentralWidget(centralWidget);
	
	connect(importer, SIGNAL(setIndexChanged(int, int, const QString &)), this, SLOT(updateTotalProgress(int, int, const QString &)));
	connect(importer, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateFileProgress(int, int)));
	
	aLoadSetsFile = new QAction(tr("Load sets information from &file..."), this);
	connect(aLoadSetsFile, SIGNAL(triggered()), this, SLOT(actLoadSetsFile()));
	aDownloadSetsFile = new QAction(tr("&Download sets information..."), this);
	connect(aDownloadSetsFile, SIGNAL(triggered()), this, SLOT(actDownloadSetsFile()));
	aExit = new QAction(tr("E&xit"), this);
	connect(aExit, SIGNAL(triggered()), this, SLOT(close()));
	
	fileMenu = menuBar()->addMenu(tr("&File"));
	fileMenu->addAction(aLoadSetsFile);
	fileMenu->addAction(aDownloadSetsFile);
	fileMenu->addSeparator();
	fileMenu->addAction(aExit);
	
	setWindowTitle(tr("Oracle importer"));
	setMinimumSize(750, 500);

	QStringList args = qApp->arguments();
	if (args.contains("-dlsets"))
		downloadSetsFile(defaultSetsUrl);
	
	statusLabel = new QLabel;
	statusBar()->addWidget(statusLabel);
	statusLabel->setText(tr("Sets data not loaded."));
}
Example #5
0
PluginSettingsTab::PluginSettingsTab(QWidget *parent) :
    QWidget(parent),
    m_model(new PluginSettingsModel(this)),
    m_view(new QListView(this)),
    m_stack(new QStackedWidget(this))
{
    m_view->setModel(m_model);
    m_view->setMaximumWidth(200);
    m_view->setFocus(Qt::OtherFocusReason);

    m_stack->setFrameStyle(QFrame::NoFrame);

    for (int i = 0; i < m_model->rowCount(); i++) {
        QScrollArea *scrollArea = new QScrollArea(this);
        QWidget *scrollWidget = new QWidget(scrollArea);
        QVBoxLayout *vbox = new QVBoxLayout(scrollWidget);
        scrollArea->setWidgetResizable(true);
        scrollArea->setWidget(scrollWidget);

        QFile file(m_model->data(m_model->index(i), PluginSettingsModel::FileNameRole).toString());
        file.open(QIODevice::ReadOnly);
        QXmlStreamReader reader;
        reader.setDevice(&file);

        while (reader.readNext() != QXmlStreamReader::Invalid) {
            if ((reader.isStartElement()) || (reader.isEndElement())) {
                break;
            }
        }

        QString title = reader.attributes().value("title").toString();

        while (!reader.atEnd()) {
            if (!reader.attributes().isEmpty()) {
                if (reader.name() == "group") {
                    vbox->addWidget(new SeparatorLabel(reader.attributes().value("title").toString(), this));
                }
                else if (reader.name() == "list") {
                    QLabel *label = new QLabel(reader.attributes().value("title").toString() + ":", this);
                    PluginSettingsCombobox *combobox = new PluginSettingsCombobox(this);
                    combobox->setKey(QString("%1/%2").arg(title).arg(reader.attributes().value("key").toString()));
                    combobox->setDefaultValue(reader.attributes().value("default").toString());

                    while (reader.readNext() != QXmlStreamReader::Invalid) {
                        if ((reader.isStartElement()) || (reader.isEndElement())) {
                            break;
                        }
                    }

                    while (reader.name() == "element") {
                        if (!reader.attributes().isEmpty()) {
                            combobox->addItem(reader.attributes().value("name").toString(), reader.attributes().value("value").toString());
                        }

                        while (reader.readNext() != QXmlStreamReader::Invalid) {
                            if ((reader.isStartElement()) || (reader.isEndElement())) {
                                break;
                            }
                        }
                    }

                    combobox->load();

                    vbox->addWidget(label);
                    vbox->addWidget(combobox);
                }
                else if (reader.name() == "boolean") {
                    PluginSettingsCheckbox *checkbox = new PluginSettingsCheckbox(this);
                    checkbox->setText(reader.attributes().value("title").toString());
                    checkbox->setKey(QString("%1/%2").arg(title).arg(reader.attributes().value("key").toString()));
                    checkbox->setDefaultValue(reader.attributes().value("default").toString());
                    checkbox->load();
                    vbox->addWidget(checkbox);
                }
                else if (reader.name() == "integer") {
                    PluginSettingsSpinbox *spinbox = new PluginSettingsSpinbox(this);
                    spinbox->setKey(QString("%1/%2").arg(title).arg(reader.attributes().value("key").toString()));
                    spinbox->setDefaultValue(reader.attributes().value("default").toString());
                    spinbox->setMinimum(reader.attributes().value("min").toString().toInt());
                    spinbox->setMaximum(reader.attributes().value("max").toString().toInt());
                    spinbox->load();
                    vbox->addWidget(new QLabel(reader.attributes().value("title").toString() + ":", this));
                    vbox->addWidget(spinbox);
                }
                else if (reader.name() == "text") {
                    PluginSettingsLineEdit *lineEdit = new PluginSettingsLineEdit(this);
                    lineEdit->setKey(QString("%1/%2").arg(title).arg(reader.attributes().value("key").toString()));
                    lineEdit->setDefaultValue(reader.attributes().value("default").toString());
                    lineEdit->load();
                    vbox->addWidget(new QLabel(reader.attributes().value("title").toString() + ":", this));
                    vbox->addWidget(lineEdit);
                }
            }

            while (reader.readNext() != QXmlStreamReader::Invalid) {
                if ((reader.isStartElement()) || (reader.isEndElement())) {
                    break;
                }
            }
        }

        vbox->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding));

        file.close();

        m_stack->addWidget(scrollArea);
    }

    QHBoxLayout *hbox = new QHBoxLayout(this);
    hbox->setContentsMargins(0, 0, 0, 0);
    hbox->addWidget(m_view);
    hbox->addWidget(m_stack);

    this->connect(m_view, SIGNAL(clicked(QModelIndex)), this, SLOT(onItemActivated(QModelIndex)));
    this->connect(m_view, SIGNAL(activated(QModelIndex)), this, SLOT(onItemActivated(QModelIndex)));
}
SettingsTabThumbnail::SettingsTabThumbnail(QWidget *parent, QMap<QString, QVariant> set, bool v) : QWidget(parent) {

	// The global settings
	globSet = set;

	this->setObjectName("tabthumb");

	verbose = v;

	// Opening the thumbnail database
	db = QSqlDatabase::database("thumbDB");

	// Style the widget
	this->setStyleSheet("#tabthumb { background: transparent; color: white; }");


	tabs = new TabWidget;
	tabs->expand(false);
	tabs->setBorderTop("rgba(150,150,150,100)",2);
	tabs->setBorderBot("rgba(150,150,150,100)",2);

	QVBoxLayout *mainLay = new QVBoxLayout;
	mainLay->addWidget(tabs);
	this->setLayout(mainLay);

	// the main scroll widget for all LOOK content
	scrollbarLook = new CustomScrollbar;
	QScrollArea *scrollLook = new QScrollArea;
	QVBoxLayout *layLook = new QVBoxLayout(scrollLook);
	QWidget *scrollWidgLook = new QWidget(scrollLook);
	scrollWidgLook->setLayout(layLook);
	scrollLook->setWidget(scrollWidgLook);
	scrollLook->setWidgetResizable(true);
	scrollLook->setVerticalScrollBar(scrollbarLook);

	// the main scroll widget for all FEEL content
	scrollbarTune = new CustomScrollbar;
	QScrollArea *scrollTune = new QScrollArea;
	QVBoxLayout *layTune = new QVBoxLayout(scrollTune);
	QWidget *scrollWidgTune = new QWidget(scrollTune);
	scrollWidgTune->setLayout(layTune);
	scrollTune->setWidget(scrollWidgTune);
	scrollTune->setWidgetResizable(true);
	scrollTune->setVerticalScrollBar(scrollbarTune);

	tabLook = new QWidget;
	tabTune = new QWidget;

	QVBoxLayout *scrollLayLook = new QVBoxLayout;
	scrollLayLook->addWidget(scrollLook);
	tabLook->setLayout(scrollLayLook);

	QVBoxLayout *scrollLayTune = new QVBoxLayout;
	scrollLayTune->addWidget(scrollTune);
	tabTune->setLayout(scrollLayTune);

	tabs->addTab(tabLook,tr("Look"));
	tabs->addTab(tabTune,tr("Fine-Tuning"));



	// The titles
	CustomLabel *titleLook = new CustomLabel("<center><h1>" + tr("Thumbnail Look") + "</h1></center>");
	layLook->addWidget(titleLook);
	layLook->addSpacing(20);
	CustomLabel *titleTune = new CustomLabel("<center><h1>" + tr("Fine-Tuning of Thumbnails") + "</h1></center>");
	layTune->addWidget(titleTune);
	layTune->addSpacing(20);


	// OPTION TO CHANGE THUMBNAIL SIZE
	CustomLabel *thumbSizeLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Thumbnail Size") + "</span></b><br><br>" + tr("Here you can adjust the thumbnail size. You can set it to any size between 20 and 256 pixel. Per default it is set to 80 pixel, but with different screen resolutions it might be nice to have them larger/smaller."));
	thumbSizeLabel->setWordWrap(true);
	QHBoxLayout *thumbSizeLay = new QHBoxLayout;
	thumbSizeSlider = new CustomSlider;
	thumbSizeSlider->setMinimum(20);
	thumbSizeSlider->setMaximum(256);
	thumbSizeSpin = new CustomSpinBox;
	thumbSizeSpin->setMinimum(20);
	thumbSizeSpin->setMaximum(256);
	thumbSizeLay->addStretch();
	thumbSizeLay->addWidget(thumbSizeSlider);
	thumbSizeLay->addWidget(thumbSizeSpin);
	thumbSizeLay->addStretch();
	layLook->addWidget(thumbSizeLabel);
	layLook->addSpacing(5);
	layLook->addLayout(thumbSizeLay);
	layLook->addSpacing(20);
	connect(thumbSizeSlider, SIGNAL(valueChanged(int)), thumbSizeSpin, SLOT(setValue(int)));
	connect(thumbSizeSpin, SIGNAL(valueChanged(int)), thumbSizeSlider, SLOT(setValue(int)));



	// OPTION TO SET SPACING BETWEEN THUMBNAILS
	borderAroundSlider = new CustomSlider;
	borderAroundSlider->setMinimum(0);
	borderAroundSlider->setMaximum(30);
	borderAroundSlider->setTickInterval(4);
	borderAroundSpin = new CustomSpinBox;
	borderAroundSpin->setMinimum(0);
	borderAroundSpin->setMaximum(30);
	borderAroundSpin->setSuffix(" px");
	CustomLabel *thbBorderAroundLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Spacing Between Thumbnail Images") + "</span></b><br><br>" + tr("The thumbnails are shown in a row at the lower or upper edge (depending on your setup). They are lined up side by side. Per default, there's no empty space between them, however exactly that can be changed here."));
	thbBorderAroundLabel->setWordWrap(true);
	QHBoxLayout *thbBorderLay = new QHBoxLayout;
	thbBorderLay->addStretch();
	thbBorderLay->addWidget(borderAroundSlider);
	thbBorderLay->addWidget(borderAroundSpin);
	thbBorderLay->addStretch();
	layLook->addWidget(thbBorderAroundLabel);
	layLook->addSpacing(5);
	layLook->addLayout(thbBorderLay);
	layLook->addSpacing(20);
	connect(borderAroundSlider, SIGNAL(valueChanged(int)), borderAroundSpin, SLOT(setValue(int)));
	connect(borderAroundSpin, SIGNAL(valueChanged(int)), borderAroundSlider, SLOT(setValue(int)));



	// OPTION TO ADJUST THE LIFTUP OF HOVERED THUMBNAIL
	thbLiftUpSlider = new CustomSlider;
	thbLiftUpSlider->setMinimum(0);
	thbLiftUpSlider->setMaximum(40);
	thbLiftUpSlider->setTickInterval(4);
	thbLiftUpSpin = new CustomSpinBox;
	thbLiftUpSpin->setMinimum(0);
	thbLiftUpSpin->setMaximum(40);
	thbLiftUpSpin->setSuffix(" px");
	CustomLabel *thbLiftUpLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Lift-up of Thumbnail Images on Hovering") + "</span></b><br><br>" + tr("When a thumbnail is hovered, it is lifted up some pixels (default 10). Here you can increase/decrease this value according to your personal preference."));
	thbLiftUpLabel->setWordWrap(true);
	QHBoxLayout *thbLiftUpLay = new QHBoxLayout;
	thbLiftUpLay->addStretch();
	thbLiftUpLay->addWidget(thbLiftUpSlider);
	thbLiftUpLay->addWidget(thbLiftUpSpin);
	thbLiftUpLay->addStretch();
	layLook->addWidget(thbLiftUpLabel);
	layLook->addSpacing(5);
	layLook->addLayout(thbLiftUpLay);
	layLook->addSpacing(20);
	connect(thbLiftUpSlider, SIGNAL(valueChanged(int)), thbLiftUpSpin, SLOT(setValue(int)));
	connect(thbLiftUpSpin, SIGNAL(valueChanged(int)), thbLiftUpSlider, SLOT(setValue(int)));



	// ADJUST THE POSITION OF THE THUMBNAILS
	CustomLabel *thbPosLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Change Thumbnail Position") + "</span></b><br><bR>" + tr("Per default the bar with the thumbnails is shown at the lower edge. However, some might find it nice and handy to have the thumbnail bar at the upper edge, so that's what can be changed here."));
	thbPosLabel->setWordWrap(true);
	QHBoxLayout *thbPosLay = new QHBoxLayout;
	thbPosTop = new CustomRadioButton(tr("Show Thumbnails at upper edge"));
	thbPosBot = new CustomRadioButton(tr("Show Thumbnails at lower edge"));
	QButtonGroup *thbPosGroup = new QButtonGroup;
	thbPosGroup->addButton(thbPosTop);
	thbPosGroup->addButton(thbPosBot);
	thbPosLay->addStretch();
	thbPosLay->addWidget(thbPosTop);
	thbPosLay->addWidget(thbPosBot);
	thbPosLay->addStretch();
	layLook->addWidget(thbPosLabel);
	layLook->addSpacing(5);
	layLook->addLayout(thbPosLay);
	layLook->addSpacing(20);



	// OPTION TO KEEP THUMBNAILS VISIBLE OR FADE THEM OUT
	CustomLabel *thbKeepVisibleLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Keep Thumbnails Visible") + "</span></b><br><bR>" + tr("Per default the Thumbnails slide out over the edge of the screen. Here you can force them to stay visible. The big image is shrunk to fit into the empty space. Note, that the thumbnails will be hidden (and only shown on mouse hovering) once you zoomed the image in/out. Resetting the zoom restores the original visibility of the thumbnails."));
	thbKeepVisibleLabel->setWordWrap(true);
	QHBoxLayout *thbKeepLay = new QHBoxLayout;
	keepVisible = new CustomCheckBox(tr("Keep Thumbnails Visible"));
	thbKeepLay->addStretch();
	thbKeepLay->addWidget(keepVisible);
	thbKeepLay->addStretch();
	layTune->addWidget(thbKeepVisibleLabel);
	layTune->addSpacing(5);
	layTune->addLayout(thbKeepLay);
	layTune->addSpacing(20);


	// OPTION TO ENABLE DYNAMIC THUMBNAIL CREATION (handy for faster harddrives)
	CustomLabel *dynamicThumbnailsLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Dynamic Thumbnail Creation") + "</span></b><br><bR>" + tr("Dynamic thumbnail creation means, that PhotoQt only sets up those thumbnail images that are actually needed, i.e. it stops once it reaches the end of the visible area and sits idle until you scroll left/right.") + "<br><br>" + tr("This feature is very handy, especially if you have bigger directories, since it doesn't occupy the CPU too long, and it doesn't create thumbnails that might never be needed."));
	dynamicThumbnailsLabel->setWordWrap(true);
	QHBoxLayout *dynamicThbLay = new QHBoxLayout;
	dynamicThumbnails = new CustomCheckBox(tr("Enable Dynamic Thumbnails"));
	dynamicThbLay->addStretch();
	dynamicThbLay->addWidget(dynamicThumbnails);
	dynamicThbLay->addStretch();
	layTune->addWidget(dynamicThumbnailsLabel);
	layTune->addSpacing(10);
	layTune->addLayout(dynamicThbLay);
	layTune->addSpacing(20);



	// OPTION TO ONLY USE FILENAME AND NO ACTUAL THUMBNAIL
	CustomLabel *filenameInsteadThbLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Use file-name-only Thumbnails") + "</span></b><br><bR>" + tr("If you don't want PhotoQt to always load the actual image thumbnail in the background, but you still want to have something for better navigating, then you can set a file-name-only thumbnail, i.e. PhotoQt wont load any thumbnail images but simply puts the file name into the box. You can also adjust the font size of this text."));
	filenameInsteadThbLabel->setWordWrap(true);
	filenameInsteadThb = new CustomCheckBox(tr("Use file-name-only Thumbnail"));
	filenameInsteadThb->setChecked(false);
	QHBoxLayout *filenameCheckLay = new QHBoxLayout;
	filenameCheckLay->addStretch();
	filenameCheckLay->addWidget(filenameInsteadThb);
	filenameCheckLay->addStretch();
	filenameFontSizeSlider = new CustomSlider;
	filenameFontSizeSpin = new CustomSpinBox;
	filenameFontSizeSlider->setEnabled(false);
	filenameFontSizeSpin->setEnabled(false);
	filenameFontSizeSlider->setMinimum(6);
	filenameFontSizeSlider->setMaximum(20);
	filenameFontSizeSlider->setValue(globSet.value("ThumbnailFilenameInsteadFontSize").toInt());
	filenameFontSizeSpin->setMinimum(6);
	filenameFontSizeSpin->setMaximum(20);
	filenameFontSizeSpin->setSuffix("pt");
	filenameFontSizeSpin->setValue(globSet.value("ThumbnailFilenameInsteadFontSize").toInt());
	QHBoxLayout *filenameSpinSliderLay = new QHBoxLayout;
	filenameSpinSliderLay->addStretch();
	filenameSpinSliderLay->addWidget(filenameFontSizeSlider);
	filenameSpinSliderLay->addWidget(filenameFontSizeSpin);
	filenameSpinSliderLay->addStretch();

	layLook->addWidget(filenameInsteadThbLabel);
	layLook->addSpacing(5);
	layLook->addLayout(filenameCheckLay);
	layLook->addLayout(filenameSpinSliderLay);
	layLook->addSpacing(20);
	connect(filenameInsteadThb, SIGNAL(toggled(bool)), filenameFontSizeSlider, SLOT(setEnabled(bool)));
	connect(filenameInsteadThb, SIGNAL(toggled(bool)), filenameFontSizeSpin, SLOT(setEnabled(bool)));
	connect(filenameFontSizeSlider, SIGNAL(valueChanged(int)), filenameFontSizeSpin, SLOT(setValue(int)));
	connect(filenameFontSizeSpin, SIGNAL(valueChanged(int)), filenameFontSizeSlider, SLOT(setValue(int)));


	// OPTION TO SWITCH BETWEEN FILENAME DIMENSION OR BOTH FOR WRITING ON THUMBNAILS
	CustomLabel *writeFilenameDimensionsLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Filename? Resolution? Or both?") + "</span></b><br><bR>" + tr("When thumbnails are displayed at the top/bottom, PhotoQt usually writes the filename on them. If wanted, this can be switched to the image resolution. Or even both can be displayed, whatever you want."));
	writeFilename = new CustomCheckBox(tr("Write Filename"));
	writeDimensions = new CustomCheckBox(tr("Write Resolution"));
	QHBoxLayout *writeCheckLay = new QHBoxLayout;
	writeCheckLay->addStretch();
	writeCheckLay->addWidget(writeFilename);
	writeCheckLay->addWidget(writeDimensions);
	writeCheckLay->addStretch();
	layLook->addWidget(writeFilenameDimensionsLabel);
	layLook->addSpacing(5);
	layLook->addLayout(writeCheckLay);
	layLook->addSpacing(20);



	// OPTION TO DISABLE THUMBNAILS ALLTOGETHER
	CustomLabel *thumbnailDisableLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Disable Thumbnails") + "</span></b><br><bR>" + tr("If you just don't need or don't want any thumbnails whatsoever, then you can disable them here completely. This option can also be toggled remotely via command line (run 'photoqt --help' for more information on that). This might increase the speed of PhotoQt a good bit, however, navigating through a folder might be a little harder without thumbnails."));
	thumbnailDisableLabel->setWordWrap(true);
	thumbDisable = new CustomCheckBox(tr("Disable Thumbnails altogether"));
	thumbDisable->setChecked(false);
	QHBoxLayout *thumbDisableLay = new QHBoxLayout;
	thumbDisableLay->addStretch();
	thumbDisableLay->addWidget(thumbDisable);
	thumbDisableLay->addStretch();
	layTune->addWidget(thumbnailDisableLabel);
	layTune->addSpacing(5);
	layTune->addLayout(thumbDisableLay);
	layTune->addSpacing(20);


	// OPTION FOR THUMBNAIL CACHE

	CustomLabel *thumbCacheLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Thumbnail Cache") + "</span></b><hr>" + tr("Thumbnails can be cached in two different ways:<br>1) File Caching (following the freedesktop.org standard) or<br>2) Database Caching (better performance and management, default option).") + "<br><br>" + tr("Both ways have their advantages and disadvantages:") + "<br>" + tr("File Caching is done according to the freedesktop.org standard and thus different applications can share the same thumbnail for the same image file. However, it's not possible to check for obsolete thumbnails (thus this may lead to many unneeded thumbnail files).") + "<br>" + tr("Database Caching doesn't have the advantage of sharing thumbnails with other applications (and thus every thumbnails has to be newly created for PhotoQt), but it brings a slightly better performance, and it allows a better handling of existing thumbnails (e.g. deleting obsolete thumbnails).") + "<br><br>" + tr("PhotoQt works with either option, though the second way is set as default.") + "<br><br>" + tr("Although everybody is encouraged to use at least one of the two options, caching can be completely disabled altogether. However, that does affect the performance and usability of PhotoQt, since thumbnails have to be newly re-created every time they are needed."));
	thumbCacheLabel->setWordWrap(true);
	QHBoxLayout *thumbCacheLay = new QHBoxLayout;
	thumbCache = new CustomCheckBox(tr("Enable Thumbnail Cache"));
	thumbCacheLay->addStretch();
	thumbCacheLay->addWidget(thumbCache);
	thumbCacheLay->addStretch();

	// OPTION TO SELECT CACHE TYPE
	QHBoxLayout *cacheOption = new QHBoxLayout;
	QButtonGroup *thbCacheGroup = new QButtonGroup;
	cacheFile = new CustomRadioButton(tr("File caching"));
	cacheDatabase = new CustomRadioButton(tr("Database caching"));
	thbCacheGroup->addButton(cacheFile);
	thbCacheGroup->addButton(cacheDatabase);
	cacheOption->addStretch();
	cacheOption->addWidget(cacheFile);
	cacheOption->addWidget(cacheDatabase);
	cacheOption->addStretch();
	cacheDatabase->setChecked(true);

	layTune->addWidget(thumbCacheLabel);
	layTune->addSpacing(5);
	layTune->addLayout(thumbCacheLay);
	layTune->addSpacing(5);
	layTune->addLayout(cacheOption);
	layTune->addSpacing(5);

	connect(thumbCache, SIGNAL(toggled(bool)), this, SLOT(updateCacheStuff()));

	// Some info about database
	QHBoxLayout *dbInfoLay = new QHBoxLayout;
	dbInfo = new CustomLabel;
	dbInfo->setAlignment(Qt::AlignCenter);
	dbInfoLay->addStretch();
	dbInfoLay->addWidget(dbInfo);
	dbInfoLay->addStretch();
	layTune->addLayout(dbInfoLay);

	// The database can be cleaned and erased
	cleanDatabase = new CustomPushButton(tr("CLEAN up Database"));
	eraseDatabase = new CustomPushButton(tr("ERASE Database"));
	QHBoxLayout *dbLay = new QHBoxLayout;
	dbLay->addStretch();
	dbLay->addWidget(cleanDatabase);
	dbLay->addWidget(eraseDatabase);
	dbLay->addStretch();

	layTune->addSpacing(10);
	layTune->addLayout(dbLay);
	layTune->addSpacing(10);

	connect(cacheDatabase, SIGNAL(toggled(bool)), cleanDatabase, SLOT(setEnabled(bool)));
	connect(cacheDatabase, SIGNAL(toggled(bool)), eraseDatabase, SLOT(setEnabled(bool)));
	connect(cacheDatabase, SIGNAL(toggled(bool)), dbInfo, SLOT(setEnabled(bool)));


	// We ask for confirmation before cleaning up the database
	confirmClean = new CustomConfirm(tr("Clean Database"),tr("Do you really want to clean up the database? This removes all obsolete thumbnails, thus possibly making PhotoQt a little faster.") + "<bR><br>" + tr("This process might take a little while."),tr("Yes, clean is good"),tr("No, don't have time for that"),QSize(450,250),"default","default",this->parentWidget());
	confirmClean->show();

	// We ask for confirmation before erasing the entire database
	confirmErase = new CustomConfirm(tr("Erase Database"),tr("Do you really want to ERASE the entire database? This removes every single item in the database! This step should never really be necessarily. After that, every thumbnail has to be newly re-created. This step cannot be reversed!"),tr("Yes, get rid of it all"),tr("Nooo, I want to keep it"),QSize(450,250),"default","default",this->parentWidget());
	confirmErase->show();

	connect(cleanDatabase, SIGNAL(clicked()), confirmClean, SLOT(animate()));
	connect(eraseDatabase, SIGNAL(clicked()), confirmErase, SLOT(animate()));

	connect(confirmClean, SIGNAL(confirmed()), this, SLOT(doCleanDatabase()));
	connect(confirmErase, SIGNAL(confirmed()), this, SLOT(doEraseDatabase()));


	layLook->addStretch();
	layTune->addStretch();

}
Example #7
0
  AdvancedScriptManager::AdvancedScriptManager(QWidget* parent) : QWidget(parent) {
    
    QHBoxLayout* hLayout = new QHBoxLayout(this);
    setLayout(hLayout);
    
    QVBoxLayout* vLayout2 = new QVBoxLayout(this);
    hLayout->addLayout(vLayout2);
    
    lstCategories = new QListWidget;
    lstCategories->setMaximumSize(200,9999);
    lstCategories->setMinimumSize(0,0);
    vLayout2->addWidget(lstCategories);
    
    addScript = new KPushButton;
    addScript->setText("Add Script");
    vLayout2->addWidget(addScript);
    
    manageCategories = new KPushButton;
    manageCategories->setText("Manage Categories");
    vLayout2->addWidget(manageCategories);
    
    
    QVBoxLayout* vLayout = new QVBoxLayout(this);
    hLayout->addLayout(vLayout);
    
    tblScript = new QTableWidget;
    if (tblScript->columnCount() < 7)
      tblScript->setColumnCount(7);
    tblScript->verticalHeader()->hide();
    tblScript->setSelectionBehavior(QAbstractItemView::SelectRows);
    vLayout->addWidget(tblScript);
    
    tabDetails = new QTabWidget;
    tabDetails->setMaximumSize(9999,175);
    vLayout->addWidget(tabDetails);
    
    tabDescriptionContent = new QWidget;
    tabDetails->addTab(tabDescriptionContent, "Description");
    
    QVBoxLayout* vLayout3 = new QVBoxLayout(tabDescriptionContent);
    tabDescriptionContent->setLayout(vLayout3);
    
    lblDescription = new QLabel();
    lblDescription->setAlignment(Qt::AlignTop);
    lblDescription->setWordWrap(true);
    
    QScrollArea *scrollArea = new QScrollArea(this);
    scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    scrollArea->setFrameShape(QFrame::StyledPanel);
    scrollArea->setWidgetResizable(true);
    scrollArea->setWidget(lblDescription);
    vLayout3->addWidget(scrollArea);
    
    
    tabInfoContent = new QWidget;
    tabDetails->addTab(tabInfoContent, "Information");
    
    QGridLayout* aGridLayout = new QGridLayout();
    tabInfoContent->setLayout(aGridLayout);
    
    lblName = new QLabel("<b>Script name: </b>");
    lblName->setWordWrap(true);
    aGridLayout->addWidget(lblName,0,0);
    lblNameValue = new QLabel();
    lblNameValue->setWordWrap(true);
    aGridLayout->addWidget(lblNameValue,0,1);
    
    lblExecNb = new QLabel("<b>Executed: </b>");
    lblExecNb->setWordWrap(true);
    aGridLayout->addWidget(lblExecNb,1,0);
    lblExecNbValue = new QLabel("0 time");
    lblExecNbValue->setWordWrap(true);
    aGridLayout->addWidget(lblExecNbValue,1,1);

    lblCreation = new QLabel("<b>Created: </b>");
    lblCreation->setWordWrap(true);
    aGridLayout->addWidget(lblCreation,0,2);
    lblCreationValue = new QLabel();
    lblCreationValue->setWordWrap(true);
    aGridLayout->addWidget(lblCreationValue,0,3);
    
    lblNbEdition = new QLabel("<b>Edited: </b>");
    lblNbEdition->setWordWrap(true);
    aGridLayout->addWidget(lblNbEdition,1,2);
    lblNbEditionValue = new QLabel("0 time");
    lblNbEditionValue->setWordWrap(true);
    aGridLayout->addWidget(lblNbEditionValue,1,3);
    
    lblLastEditDate = new QLabel("<b>Last edition: </b>");
    lblLastEditDate->setWordWrap(true);
    aGridLayout->addWidget(lblLastEditDate,2,0);
    lblLastEditDateValue = new QLabel();
    lblLastEditDateValue->setWordWrap(true);
    aGridLayout->addWidget(lblLastEditDateValue,2,1);
    
    lblMoyExecTime = new QLabel("<b>Moy. exec time:");
    lblMoyExecTime->setWordWrap(true);
    aGridLayout->addWidget(lblMoyExecTime,2,2);
    lblMoyExecTimeValue = new QLabel();
    lblMoyExecTimeValue->setWordWrap(true);
    aGridLayout->addWidget(lblMoyExecTimeValue,2,3);
    
    aGridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed), 0,4);
    
    aGridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding), 3,0);
    
    tblVersion = new QTableWidget;
    tblVersion->setSelectionBehavior(QAbstractItemView::SelectRows);
    tblVersion->setColumnCount(2);
    tblVersion->verticalHeader()->hide();
    tabDetails->addTab(tblVersion, "Versions");
    
    tblExecute = new QTableWidget; 
    tblExecute->setColumnCount(4);
    tblExecute->verticalHeader()->hide();
    tblExecute->setSelectionBehavior(QAbstractItemView::SelectRows);
    setupHeaderLog();
    tabDetails->addTab(tblExecute, "Log");
    
    connect( lstCategories, SIGNAL( currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadScriptList(QListWidgetItem*, QListWidgetItem*)));
    connect( tblScript, SIGNAL( cellClicked ( int, int)), this, SLOT(scriptSelected(int, int)));
    
    loadCategories();
    setupHeader();
    setupHeaderVersion();
    lstCategories->setCurrentRow(0);
    //loadScriptList("Backup");
  }
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //ui->setupUi(this);

    setFixedHeight(768); //1024
    setFixedWidth(768);

    //Define page structure
    QWidget * page = new QWidget(this);
    page->setFixedWidth(this->width());
    page->setFixedHeight(this->height());
    page->setStyleSheet("background-color:white;");
    QVBoxLayout * pageLayout = new QVBoxLayout();


    //Define the fixed header
    QWidget * header = new QWidget(page);
    header->setFixedWidth(page->width());
    QGridLayout * headerLayout = new QGridLayout();
    headerLayout->setHorizontalSpacing(2);
    headerLayout->setVerticalSpacing(2);

    QLabel * numTable = new QLabel();
    QPixmap numTableIm(":/Images/images/NumTable.png");
   // numTable->setStyleSheet("margin-right: 5px");
    numTable->setPixmap(numTableIm);
    numTable->setFixedSize(numTableIm.rect().size());

    QLabel * banner = new QLabel(header);
    QPixmap bannerIm(":/Images/images/Banner.png");
    banner->setPixmap(bannerIm);
    banner->setFixedSize(bannerIm.rect().size());

    QPushButton * pain = new QPushButton("");
    QPixmap painIm(":/Images/images/Pain.png");
    QIcon painIcon(painIm);
    pain->setIcon(painIcon);
    pain->setIconSize(painIm.rect().size());
    pain->setFixedSize(painIm.rect().size());

    QPushButton * eau = new QPushButton("");
    QPixmap eauIm(":/Images/images/eau.png");
    QIcon eauIcon(eauIm);
    eau->setIcon(eauIcon);
    eau->setIconSize(eauIm.rect().size());
    eau->setFixedSize(eauIm.rect().size());

    QPushButton * serveur = new QPushButton("");
    QPixmap serveurIm(":/Images/images/Serveur.png");
    QIcon serveurIcon(serveurIm);
    serveur->setIcon(serveurIcon);
    serveur->setIconSize(serveurIm.rect().size());
    serveur->setFixedSize(serveurIm.rect().size());


    headerLayout->addWidget(numTable, 0, 0, 2, 0);
    headerLayout->addWidget(banner, 0, 1, 2, 1);
    headerLayout->addWidget(serveur,0, 2, 2, 2);
    headerLayout->addWidget(pain, 0, 3);
    headerLayout->addWidget(eau, 1, 3);
    header->setLayout(headerLayout);


    //Define the widget containing all the meals (Tabs)
    QTabWidget * repasFrame = new QTabWidget(page);

    //For one Meal, define the widget containing all the bands
    QWidget * area = new QWidget(repasFrame);
    QScrollArea * sArea = new QScrollArea(area);
    QPalette * palette = new QPalette();
    palette->setColor(QPalette::Background, Qt::white);
    sArea->setPalette(*palette);
    sArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    sArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    sArea->setFixedWidth(page->width() -20);
    sArea->setFixedHeight(page->height() - header->height() - 125);

    bands = new QWidget();
    bands->setFixedWidth(page->width() -25);
   // bands->setMinimumHeight(page->height() - header->height() - 125);
    bands->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
    bandsLayout = new QVBoxLayout(bands);
    Headband* menus = HeadbandFactory::buildMenus(bands);
    bandList.append(menus);
    bandsLayout->addWidget(menus);
    usefulLabel = new QLabel();
    bandsLayout->addWidget(usefulLabel);
    bands->setLayout(bandsLayout);
    sArea->setWidget(bands);


    repasFrame->setFixedWidth(page->width());
    repasFrame->setFixedHeight(page->height() - header->height());
    repasFrame->addTab(area, "Repas 1");
    repasFrame->addTab(new QLabel(), "+");


    //Define the confirmation button
    QPushButton * confirmButton = new QPushButton("");
    QPixmap confirmIm(":/Images/images/Confirm.jpg");
    QIcon confirmIcon(confirmIm);
    confirmButton->setIcon(confirmIcon);
    confirmButton->setIconSize(confirmIm.rect().size());
    confirmButton->setFixedSize(confirmIm.rect().size());


    //Define the 'languette' and its 'etiquette'
    QList<QList<QObject*> > bigDataList;
    languetteContainer = new LanguetteContainer(bigDataList);
    languetteContainer->setFixedSize(760, 855);
    Etiquette * etiquette = new Etiquette(languetteContainer, confirmButton, page);


    //Link final page layouts
    pageLayout->addWidget(header);
    pageLayout->addWidget(repasFrame);
    pageLayout->addWidget(etiquette);
    pageLayout->addWidget(confirmButton);
    pageLayout->addWidget(languetteContainer);
    page->setLayout(pageLayout);


    //connect all slots
    connect(etiquette, SIGNAL(updateLanguetteInfo()), this, SLOT(recapLanguette()));
    connect(menus, SIGNAL(itemSelect(Headband_Item*)), this, SLOT(changeMenu(Headband_Item*)));
    connect(confirmButton, SIGNAL(clicked()), this, SLOT(confirmMeal()));
    connect(pain, SIGNAL(clicked()), this, SLOT(callBread()));
    connect(eau, SIGNAL(clicked()), this, SLOT(callWater()));
    connect(serveur, SIGNAL(clicked()), this, SLOT(callServer()));

    setCentralWidget(page);
}
Example #9
0
BlitzMainWindow::BlitzMainWindow()
    : QMainWindow()
{
    setWindowTitle(tr("Blitz Effect Test"));
    QScrollArea *sa = new QScrollArea(this);
    lbl = new QLabel;
    sa->setWidget(lbl);
    setCentralWidget(sa);

    QToolBar *tBar = addToolBar(tr("Effect Options"));
    QAction *openAct = tBar->addAction(tr("Open"), this, SLOT(slotOpen()));
    QAction *revertAct = tBar->addAction(tr("Revert"), this, SLOT(slotRevert()));
    qualityCB = new QCheckBox(tr("High Quality"), tBar);
    qualityCB->setChecked(true);
    tBar->addWidget(qualityCB);

    QMenuBar *mBar = menuBar();
    QMenu *fileMnu = mBar->addMenu(tr("File"));
    fileMnu->addAction(openAct);
    fileMnu->addAction(revertAct);
    fileMnu->addSeparator();
    fileMnu->addAction(tr("Close"), this, SLOT(close()));

    QMenu *effectMnu = mBar->addMenu(tr("Effects"));
    effectMnu->addAction(tr("Grayscale (MMX)"), this, SLOT(slotGrayscale()));
    effectMnu->addAction(tr("Invert (MMX)"), this, SLOT(slotInvert()));

    QMenu *subMnu = effectMnu->addMenu(tr("Threshold"));
    subMnu->addAction(tr("Threshold (Default)"), this, SLOT(slotThreshold()));
    subMnu->addAction(tr("Threshold (Red)"), this, SLOT(slotThresholdRed()));
    subMnu->addAction(tr("Threshold (Green)"), this, SLOT(slotThresholdGreen()));
    subMnu->addAction(tr("Threshold (Blue)"), this, SLOT(slotThresholdBlue()));
    subMnu->addAction(tr("Threshold (Alpha)"), this, SLOT(slotThresholdAlpha()));
    subMnu = effectMnu->addMenu(tr("Intensity (MMX)"));
    subMnu->addAction(tr("Increment Intensity"), this, SLOT(slotIncIntensity()));
    subMnu->addAction(tr("Decrement Intensity"), this, SLOT(slotDecIntensity()));
    subMnu->addSeparator();
    subMnu->addAction(tr("Increment Red Intensity"), this, SLOT(slotIncRedIntensity()));
    subMnu->addAction(tr("Decrement Red Intensity"), this, SLOT(slotDecRedIntensity()));
    subMnu->addAction(tr("Increment Green Intensity"), this, SLOT(slotIncGreenIntensity()));
    subMnu->addAction(tr("Decrement Green Intensity"), this, SLOT(slotDecGreenIntensity()));
    subMnu->addAction(tr("Increment Blue Intensity"), this, SLOT(slotIncBlueIntensity()));
    subMnu->addAction(tr("Decrement Blue Intensity"), this, SLOT(slotDecBlueIntensity()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Spiff"), this, SLOT(slotSpiff()));
    effectMnu->addAction(tr("Dull"), this, SLOT(slotDull()));
    effectMnu->addSeparator();
    effectMnu->addAction(tr("Desaturate"), this, SLOT(slotDesaturate()));
    effectMnu->addAction(tr("Fade"), this, SLOT(slotFade()));
    effectMnu->addAction(tr("Flatten"), this, SLOT(slotFlatten()));
    effectMnu->addSeparator();
    effectMnu->addAction(tr("Sharpen"), this, SLOT(slotSharpen()));
    effectMnu->addAction(tr("Blur"), this, SLOT(slotBlur()));
    effectMnu->addAction(tr("Gaussian Sharpen (MMX)"), this, SLOT(slotGaussianSharpen()));
    effectMnu->addAction(tr("Gaussian Blur (MMX)"), this, SLOT(slotGaussianBlur()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Sobel Edge (MMX)"), this, SLOT(slotEdge()));
    effectMnu->addAction(tr("Convolve Edge (MMX)"), this, SLOT(slotConvolveEdge()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Equalize"), this, SLOT(slotEqualize()));
    effectMnu->addAction(tr("Normalize"), this, SLOT(slotNormalize()));
    effectMnu->addAction(tr("Despeckle"), this, SLOT(slotDespeckle()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Charcoal"), this, SLOT(slotCharcoal()));
    effectMnu->addAction(tr("Swirl"), this, SLOT(slotSwirl()));
    effectMnu->addAction(tr("Implode"), this, SLOT(slotImplode()));
    effectMnu->addAction(tr("Wave"), this, SLOT(slotWave()));
    effectMnu->addAction(tr("Oil Paint"), this, SLOT(slotOilpaint()));
    effectMnu->addAction(tr("Emboss"), this, SLOT(slotEmboss()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Smoothscale Filtered..."), this, SLOT(slotSmoothscaleFiltered()));
    effectMnu->addSeparator();
    effectMnu->addAction(tr("Modulate..."), this, SLOT(slotModulate()));
    effectMnu->addSeparator();

    effectMnu->addAction(tr("Gradient..."), this, SLOT(slotGradient()));
    effectMnu->addAction(tr("Unbalanced Gradient..."), this, SLOT(slotUnbalancedGradient()));
    effectMnu->addAction(tr("8bpp Gradient..."), this, SLOT(slotGrayscaleGradient()));
    effectMnu->addAction(tr("8bpp Unbalanced Gradient..."), this, SLOT(slotGrayscaleUnbalancedGradient()));

    resize(sizeHint());
}
Example #10
0
ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
    : ActivateDialog(parent, Qt::Window)
    , activeChatroomWidget(nullptr)
    , settingsWidget(settingsWidget)
{
    QVBoxLayout* boxLayout = new QVBoxLayout(this);
    boxLayout->setMargin(0);
    boxLayout->setSpacing(0);

    splitter = new QSplitter(this);
    setStyleSheet("QSplitter{color: rgb(255, 255, 255);background-color: rgb(255, 255, 255);alternate-background-color: rgb(255, 255, 255);border-color: rgb(255, 255, 255);gridline-color: rgb(255, 255, 255);selection-color: rgb(255, 255, 255);selection-background-color: rgb(255, 255, 255);}QSplitter:handle{color: rgb(255, 255, 255);background-color: rgb(255, 255, 255);}");
    splitter->setHandleWidth(6);

    QWidget *friendWidget = new QWidget();
    friendWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    friendWidget->setAutoFillBackground(true);

    friendLayout = new FriendListLayout();
    friendLayout->setMargin(0);
    friendLayout->setSpacing(0);
    friendWidget->setLayout(friendLayout);

    onGroupchatPositionChanged(Settings::getInstance().getGroupchatPosition());

    QScrollArea *friendScroll = new QScrollArea(this);
    friendScroll->setMinimumWidth(220);
    friendScroll->setFrameStyle(QFrame::NoFrame);
    friendScroll->setLayoutDirection(Qt::RightToLeft);
    friendScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    friendScroll->setStyleSheet(Style::getStylesheet(":/ui/friendList/friendList.css"));
    friendScroll->setWidgetResizable(true);
    friendScroll->setWidget(friendWidget);

    QWidget* contentWidget = new QWidget(this);
    contentWidget->setAutoFillBackground(true);
    contentLayout = new ContentLayout(contentWidget);
    contentLayout->setMargin(0);
    contentLayout->setSpacing(0);

    splitter->addWidget(friendScroll);
    splitter->addWidget(contentWidget);
    splitter->setStretchFactor(1, 1);
    splitter->setCollapsible(1, false);
    boxLayout->addWidget(splitter);

    connect(splitter, &QSplitter::splitterMoved, this, &ContentDialog::saveSplitterState);

    connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, this, &ContentDialog::onGroupchatPositionChanged);

    setMinimumSize(500, 220);
    setAttribute(Qt::WA_DeleteOnClose);

    QByteArray geometry = Settings::getInstance().getDialogGeometry();

    if (!geometry.isNull())
        restoreGeometry(geometry);
    else
        resize(720, 400);


    QByteArray splitterState = Settings::getInstance().getDialogSplitterState();

    if (!splitterState.isNull())
        splitter->restoreState(splitterState);

    currentDialog = this;

    setAcceptDrops(true);

    new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
    new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousContact()));
    new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextContact()));
    new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousContact()));
    new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));

    connect(Core::getInstance(), &Core::usernameSet, this, &ContentDialog::updateTitleUsername);

    Translator::registerHandler(std::bind(&ContentDialog::retranslateUi, this), this);
}
void MusicWebDJRadioInfoWidget::createLabels()
{
    initFirstWidget();
    m_container->show();

    layout()->removeWidget(m_mainWindow);
    QScrollArea *scrollArea = new QScrollArea(this);
    scrollArea->verticalScrollBar()->setStyleSheet(MusicUIObject::MScrollBarStyle01);
    scrollArea->setWidgetResizable(true);
    scrollArea->setFrameShape(QFrame::NoFrame);
    scrollArea->setAlignment(Qt::AlignLeft);
    scrollArea->setWidget(m_mainWindow);
    layout()->addWidget(scrollArea);

    QWidget *function = new QWidget(m_mainWindow);
    function->setStyleSheet(MusicUIObject::MCheckBoxStyle01 + MusicUIObject::MPushButtonStyle03);
    QVBoxLayout *grid = new QVBoxLayout(function);

    QWidget *firstTopFuncWidget = new QWidget(function);
    QHBoxLayout *firstTopFuncLayout = new QHBoxLayout(firstTopFuncWidget);
    QLabel *firstLabel = new QLabel(function);
    firstLabel->setText(tr("<font color=#158FE1> DJRadio > %1 </font>").arg(m_currentPlaylistItem.m_name));
    QPushButton *backButton = new QPushButton(tr("Back"));
    backButton->setFixedSize(90, 30);
    backButton->setStyleSheet(MusicUIObject::MPushButtonStyle03);
    backButton->setCursor(QCursor(Qt::PointingHandCursor));
    connect(backButton, SIGNAL(clicked()), this, SIGNAL(backToMainMenu()));
    firstTopFuncLayout->addWidget(firstLabel);
    firstTopFuncLayout->addWidget(backButton);
    grid->addWidget(firstTopFuncWidget);
    ////////////////////////////////////////////////////////////////////////////
    QWidget *topFuncWidget = new QWidget(function);
    QHBoxLayout *topFuncLayout = new QHBoxLayout(topFuncWidget);

    m_iconLabel = new QLabel(topFuncWidget);
    m_iconLabel->setPixmap(QPixmap(":/image/lb_warning").scaled(180, 180));
    m_iconLabel->setFixedSize(210, 180);
    ////////////////////////////////////////////////////////////////////////////

    QWidget *topLineWidget = new QWidget(topFuncWidget);
    QVBoxLayout *topLineLayout = new QVBoxLayout(topLineWidget);
    topLineLayout->setContentsMargins(10, 5, 5, 0);
    QLabel *nameLabel = new QLabel(topLineWidget);
    QFont nameFont = nameLabel->font();
    nameFont.setPixelSize(20);
    nameLabel->setFont(nameFont);
    nameLabel->setStyleSheet(MusicUIObject::MFontStyle01);
    nameLabel->setText("-");
    QLabel *singerLabel = new QLabel(topLineWidget);
    singerLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
    singerLabel->setText("-");
    QLabel *playCountLabel = new QLabel(topLineWidget);
    playCountLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
    QLabel *updateTimeLabel = new QLabel(topLineWidget);
    updateTimeLabel->setStyleSheet(MusicUIObject::MColorStyle04 + MusicUIObject::MFontStyle03);
    updateTimeLabel->setText("-");

    topLineLayout->addWidget(nameLabel);
    topLineLayout->addWidget(singerLabel);
    topLineLayout->addWidget(playCountLabel);
    topLineLayout->addWidget(updateTimeLabel);
    topLineWidget->setLayout(topLineLayout);

    topFuncLayout->addWidget(m_iconLabel);
    topFuncLayout->addWidget(topLineWidget);
    topFuncWidget->setLayout(topFuncLayout);
    grid->addWidget(topFuncWidget);
    ////////////////////////////////////////////////////////////////////////////

    QWidget *functionWidget = new QWidget(this);
    functionWidget->setStyleSheet(MusicUIObject::MPushButtonStyle03);
    QHBoxLayout *hlayout = new QHBoxLayout(functionWidget);
    m_songButton = new QPushButton(functionWidget);
    m_songButton->setText(tr("songItems"));
    m_songButton->setFixedSize(100, 25);
    m_songButton->setCursor(QCursor(Qt::PointingHandCursor));
    hlayout->addWidget(m_songButton);
    hlayout->addStretch(1);
    functionWidget->setLayout(hlayout);
    QButtonGroup *group = new QButtonGroup(this);
    group->addButton(m_songButton, 0);
    connect(group, SIGNAL(buttonClicked(int)), m_container, SLOT(setCurrentIndex(int)));

#ifdef Q_OS_UNIX
    m_songButton->setFocusPolicy(Qt::NoFocus);
#endif
    grid->addWidget(functionWidget);
    //////////////////////////////////////////////////////////////////////
    grid->addWidget(m_container);
    grid->addStretch(1);

    function->setLayout(grid);
    m_mainWindow->layout()->addWidget(function);

    m_resizeWidgets << nameLabel << singerLabel << playCountLabel << updateTimeLabel;
}
Example #12
0
StegoFrame::StegoFrame(QWidget* parent) : QMainWindow(parent) {
  QSplitter *central = new QSplitter(Qt::Vertical);
  QScrollArea *hscroll = new QScrollArea();
  QScrollArea *pscroll = new QScrollArea();
  QDomElement stegoDom;
  
  model = new StegoModel();
  model->addView(this);
  
  hw = new HistogramWidget(this, model);
  pw = new PairWidget(this, model);

  fdock = new FeatureDock(this, model);
  cdock = new ConfigDock(hw, pw, this);
//   gdock = new GraphDock(this);
//   tdock = new TableDock(this, model);
  ldial = new LoadDialog(this);
  
  hscroll->setWidgetResizable(1);
  hscroll->setAlignment(Qt::AlignLeft);
//   hscroll->setBackgroundRole(QPalette::Dark);
  hscroll->setWidget(hw);
  pscroll->setWidgetResizable(1);
  pscroll->setAlignment(Qt::AlignLeft);
//   pscroll->setBackgroundRole(QPalette::Dark);
  pscroll->setWidget(pw);
  central->addWidget(hscroll);
  central->addWidget(pscroll);
//   scroll1->setWidget(central);
//   central->show();
  
  setCentralWidget(central);
  addDockWidget(Qt::LeftDockWidgetArea, fdock);
  addDockWidget(Qt::BottomDockWidgetArea, cdock);
//   addDockWidget(Qt::BottomDockWidgetArea, gdock);
//   addDockWidget(Qt::BottomDockWidgetArea, tdock);
  
  openFeaturesAction = new QAction(tr("Open"), this);
  loadFeaturesAction = new QAction(tr("Load"), this);
  openDocAction = new QAction(tr("Open"), this);
  saveDocAction = new QAction(tr("Save"), this);
  mmdAction  = new QAction(tr("MMDs"), this);
  svmAction  = new QAction(tr("SVM classification"), this);
  muAction   = new QAction(tr("Mus"), this);
  
  fdial = new QFileDialog(this);
  fdial->setFileMode(QFileDialog::ExistingFiles);
  fdial->setNameFilter(tr("Features (*.fv)"));
  fdial->setAcceptMode(QFileDialog::AcceptOpen);
  fdial->setDirectory(tr("."));
  
  docMenu = menuBar()->addMenu(tr("Document"));
  fileMenu = menuBar()->addMenu(tr("Features"));
  calcMenu = menuBar()->addMenu(tr("Calculate"));
  fileMenu->addAction(openFeaturesAction);
  fileMenu->addAction(loadFeaturesAction);
  docMenu->addAction(openDocAction);
  docMenu->addAction(saveDocAction);
  calcMenu->addAction(muAction);
  calcMenu->addAction(mmdAction);
  calcMenu->addAction(svmAction);
  
  progress = new QProgressBar(statusBar());
  statusLabel = new QLabel(tr("Ready."));
  statusBar()->addPermanentWidget(statusLabel, 9);
  statusBar()->addPermanentWidget(progress, 1);
  
  connect(openFeaturesAction, SIGNAL(triggered(bool)), this, SLOT(openCollection()));
  connect(loadFeaturesAction, SIGNAL(triggered(bool)), ldial, SLOT(open()));
  connect(saveDocAction, SIGNAL(triggered(bool)), this, SLOT(saveXML()));
  connect(mmdAction, SIGNAL(triggered(bool)), this, SLOT(calcMMDs()));
  connect(svmAction, SIGNAL(triggered(bool)), this, SLOT(classify()));
  connect(muAction, SIGNAL(triggered(bool)), this, SLOT(calcMus()));
  connect(ldial, SIGNAL(accepted()), this, SLOT(loadFeatures()));
  
  document = new QDomDocument();
  xmlFile = new QFile("stegodoc.xml");
  if (xmlFile->exists()) {
    openXML();
//     if (document->firstChildElement().tagName() != QString("stegosaurus"))
//       printf("lol \n");
    sets = document->firstChildElement().firstChildElement(QString("sets"));
    if (sets.isNull()) {
      sets = document->createElement(QString("sets"));
      stegoDom.appendChild(sets);
    }
    mmds = document->firstChildElement().firstChildElement(QString("mmds"));
    if (sets.isNull()) {
      sets = document->createElement(QString("mmds"));
      stegoDom.appendChild(sets);
    }
  } else {
    stegoDom = document->createElement(QString("stegosaurus"));
    sets = document->createElement(QString("sets"));
    stegoDom.appendChild(sets);
    document->appendChild(stegoDom);
  }
  
  setMinimumSize(1280, 720);
  setWindowTitle("Stegosaurus");
}
AppStoreRankingWidget::AppStoreRankingWidget(QWidget *parent)
{
	QString paths[] =
	{
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/dota2.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/messages.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/safari.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/ibooks.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/launchpad.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/maps.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/facetime.png",
		Webbox::Utility::PathUtil::GetCurrentExePath() +"/Skin/img/gamecenter.png"
	};


	QColor colors[] =
	{
		QColor(255, 0, 0),
		QColor(0, 255, 0),
		QColor(0, 0, 255),
		QColor(100, 100, 100),
		QColor(255, 0, 255),
		QColor(0, 255, 255),
		QColor(0, 100, 230),
		QColor(255, 100, 0, 100),
	};

	contentWidget = new RankingWidget();

	for (int i = 0; i < 8; ++i)
	{
		RankingLabel *label = new RankingLabel(700, 100, 102, paths[i], QString::fromWCharArray(L"Office 2015"), QString::fromWCharArray(L"Windows 7+"), QString::fromWCharArray(L"Æƽâ"));
		label->setColor(colors[7]);
		contentWidget->addItem(label);
	}

	QScrollArea *scrollArea = new QScrollArea;
	scrollArea->setGeometry(contentWidget->geometry());
	scrollArea->setWidget(contentWidget); // MainWidget is the container widget i.e. the window itself
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

	/*scrollArea->viewport()->setAutoFillBackground(true);
	scrollArea->setStyleSheet("background-color:transparent;");*/

	scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar{background:transparent; width: 10px;}"
		"QScrollBar::handle{background:lightgray; border:2px solid transparent; border-radius:5px;}"
		"QScrollBar::handle:hover{background:gray;}"
		"QScrollBar::sub-line{background:transparent;}"
		"QScrollBar::add-line{background:transparent;}");
 
	NavControlWidget *navWidget = new NavControlWidget();
 
	QHBoxLayout *bot_layout = new QHBoxLayout();
	bot_layout->addStretch(); 
	bot_layout->addWidget(navWidget);
	bot_layout->addStretch();

	QVBoxLayout *mainLayout = new QVBoxLayout(); 
	mainLayout->addWidget(scrollArea);
	mainLayout->addLayout(bot_layout);

	setLayout(mainLayout);
}
Example #14
0
EditRubyMeasureView::EditRubyMeasureView()
  : QWidget()
{
  QVBoxLayout * layout = new QVBoxLayout();
  layout->setContentsMargins(0,0,0,0);
  setLayout(layout);
  QScrollArea * scrollArea = new QScrollArea();
  layout->addWidget(scrollArea);
  scrollArea->setWidgetResizable(true);

  QWidget * scrollWidget = new QWidget();
  scrollWidget->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Preferred);
  scrollArea->setWidget(scrollWidget);

  m_mainVLayout = new QVBoxLayout();
  m_mainVLayout->setContentsMargins(5,5,5,5);
  m_mainVLayout->setSpacing(5);
  m_mainVLayout->setAlignment(Qt::AlignTop);
  scrollWidget->setLayout(m_mainVLayout);

  QLabel * measureOptionTitleLabel = new QLabel("Name");
  measureOptionTitleLabel->setObjectName("H2");
  m_mainVLayout->addWidget(measureOptionTitleLabel);

  QRegExp nameRegex("^\\S.*");
  QRegExpValidator* validator = new QRegExpValidator(nameRegex, this);

  nameLineEdit = new QLineEdit();
  nameLineEdit->setValidator(validator);
  m_mainVLayout->addWidget(nameLineEdit);

  QLabel * descriptionTitleLabel = new QLabel("Description");
  descriptionTitleLabel->setObjectName("H2");
  m_mainVLayout->addWidget(descriptionTitleLabel);

  descriptionTextEdit = new QTextEdit();
  descriptionTextEdit->setFixedHeight(70);
  descriptionTextEdit->setAcceptRichText(false);
  descriptionTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  descriptionTextEdit->setTabChangesFocus(true);
  m_mainVLayout->addWidget(descriptionTextEdit);

  QLabel * modelerDescriptionTitleLabel = new QLabel("Modeler Description");
  modelerDescriptionTitleLabel->setObjectName("H2");
  m_mainVLayout->addWidget(modelerDescriptionTitleLabel);

  modelerDescriptionLabel = new QLabel();
  modelerDescriptionLabel->setWordWrap(true);
  m_mainVLayout->addWidget(modelerDescriptionLabel);

  QFrame * line2 = new QFrame();
  line2->setFrameShape(QFrame::HLine);
  line2->setFrameShadow(QFrame::Sunken);
  m_mainVLayout->addWidget(line2);

  QLabel * inputsTitleLabel = new QLabel("Inputs");
  inputsTitleLabel->setObjectName("H2");
  m_mainVLayout->addWidget(inputsTitleLabel);

  m_inputsVLayout = new QVBoxLayout();
  m_inputsVLayout->setContentsMargins(0,0,0,0);
  m_inputsVLayout->setSpacing(10);

  m_mainVLayout->addLayout(m_inputsVLayout);

  m_mainVLayout->addStretch();
}
Example #15
0
void QtUnit::mousePressEvent(QMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;
    if (!this->IsClickable())
        return;
    QVBoxLayout *objGroupLayout = new QVBoxLayout();
    QScrollArea *objScroll = new QScrollArea(objDetail);
    objScroll->setStyleSheet("background-color: rgb(25, 25, 25);");
    objScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    objScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    QWidget *scrollChild = new QWidget();
    QGridLayout *objGrid = new QGridLayout(scrollChild);
    objGrid->setSizeConstraint(QLayout::SetMinAndMaxSize);

    QLayout *currentLayout = NULL;
    QLayoutItem *child = NULL;
    if (objDetail) {
        if ((currentLayout = objDetail->layout())) {
            while ((child = currentLayout->takeAt(0)) != 0)
                delete child->widget();
            delete currentLayout;
        }
        
    }

    objGroupLayout->addWidget(objScroll);

    QLabel *overlapLab = new QLabel("overlap: ");
    QLabel *overlapVal = new QLabel(QString::number(((Column *)node)->GetOverlap()));
    objGrid->addWidget(overlapLab, 0, 0);
    objGrid->addWidget(overlapVal, 0, 1);

    QLabel *synapsesLab = new QLabel("synaptic details");
    objGrid->addWidget(synapsesLab, 1, 0, 1, 3);
    QLabel *idx = new QLabel("Idx");
    QLabel *coord = new QLabel("Coord");
    QLabel *firing = new QLabel("Firing");
    QLabel *perm = new QLabel("Perm");
    objGrid->addWidget(idx, 2, 0);
    objGrid->addWidget(coord, 2, 1);
    objGrid->addWidget(firing, 2, 2);
    objGrid->addWidget(perm, 2, 3);

    Column *col = (Column *)node;
    DendriteSegment *segment = col->GetProximalDendriteSegment();
    std::vector<Synapse *> syns  = segment->GetSynapses();
    for (int i=0; i<col->GetRecFieldSz(); i++) {
        char synCoordStr[32];
        memset(synCoordStr, 0, sizeof(synCoordStr));
        unsigned int x = syns[i]->GetX(), y = syns[i]->GetY();
        snprintf(synCoordStr, sizeof(synCoordStr), "(%d, %d)", x, y);
        float p = syns[i]->GetPerm();

        QLabel *synIdx = new QLabel(QString("%1: ").arg(i));
        QLabel *synCoordLab = new QLabel(synCoordStr);
        QLabel *synFiring = new QLabel(QString("%1").arg(syns[i]->IsFiring()? 1 : 0));
        QLabel *synPerm = new QLabel(QString("%1: ").arg(p));
        objGrid->addWidget(synIdx, 3+i, 0, 1, 1);
        objGrid->addWidget(synCoordLab, 3+i, 1, 1, 1);
        objGrid->addWidget(synFiring, 3+i, 2, 1, 1);
        objGrid->addWidget(synPerm, 3+i, 3, 1, 1);
    }

    // Note: must add the layout of widget before calling setWidget() or won't
    // be visible.
    objScroll->setWidget(scrollChild);
    objDetail->setLayout(objGroupLayout);
}
Example #16
0
void MainPanel::init()
{
    if (!db.init())
    {
        QMessageBox error;
        error.critical(0, "Error!", "An error occured while trying to load the database.");
        exit(EXIT_FAILURE);
        return;
    }

    stack = new QStackedWidget(this);

    QString style = getStylesheet(":/Styles/Content.css");
    // Prepare UI objects for each tab
    libraryPtr = new Library(db);
    libraryPtr->setStyleSheet(style);
    browserPtr = new Browser();
    browserPtr->setStyleSheet(style);
    stack->addWidget(libraryPtr);
    stack->addWidget(browserPtr);
    stack->setCurrentWidget(libraryPtr);

    // System layout
    QHBoxLayout* systemLayout = new QHBoxLayout;
    systemLayout->setSpacing(0);
    systemLayout->setMargin(8);

    // Header spacing
    QVBoxLayout* topLayout = new QVBoxLayout;
    topLayout->setMargin(0);

    // Header layout
    QHBoxLayout* headerLayout = new QHBoxLayout;
    headerLayout->setSpacing(0);
    headerLayout->setMargin(0);

    // Window title
    QLabel* windowTitle = new QLabel(this);
    windowTitle->setObjectName("windowTitle");
    windowTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    windowTitle->setMinimumWidth(175);
    windowTitle->setMaximumWidth(175);
    windowTitle->setAlignment(Qt::AlignTop);
    windowTitle->setFont(QFont("Sansation", 18));
    windowTitle->setText("Project \nASCENSION");
    windowTitle->setStyleSheet("color: #7D818C;");
    windowTitle->setAttribute(Qt::WA_TransparentForMouseEvents);

    // Post-initialization header spacing
    topLayout->addLayout(systemLayout);
    topLayout->addLayout(headerLayout);
    topLayout->addSpacing(10);

    headerLayout->addSpacing(20);
    headerLayout->addWidget(windowTitle);
    headerLayout->addSpacing(40);

    // Header tabs
    libraryTab = new TabLabel(this);
    libraryTab = g_tabFactory(libraryTab, "libraryTab", "LIBRARY");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(libraryTab);
    libraryTab->setStyleSheet("font-weight: bold; color: lightgreen;");

    storeTab = new TabLabel(this);
    storeTab = g_tabFactory(storeTab, "storeTab", "  STORE");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(storeTab);

    modsTab = new TabLabel(this);
    modsTab = g_tabFactory(modsTab, "modsTab", " MODS");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(modsTab);

    newsTab = new TabLabel(this);
    newsTab = g_tabFactory(newsTab, "newsTab", "NEWS");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(newsTab);

    browserTab = new TabLabel(this);
    browserTab = g_tabFactory(browserTab, "browserTab", "BROWSER");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(browserTab);

    activeTab = libraryTab;

    headerLayout->addStretch();

    // System buttons
    systemLayout->addStretch();

    // Minimize
    QPushButton* pushButtonMinimize = new QPushButton("", this);
    pushButtonMinimize->setObjectName("pushButtonMinimize");
    systemLayout->addWidget(pushButtonMinimize);
    QObject::connect(pushButtonMinimize, SIGNAL(clicked()), this, SLOT(pushButtonMinimize()));

    // Maximize
    QPushButton* pushButtonMaximize = new QPushButton("", this);
    pushButtonMaximize->setObjectName("pushButtonMaximize");
    systemLayout->addWidget(pushButtonMaximize);
    QObject::connect(pushButtonMaximize, SIGNAL(clicked()), this, SLOT(pushButtonMaximize()));

    // Close
    QPushButton* pushButtonClose = new QPushButton("", this);
    pushButtonClose->setObjectName("pushButtonClose");
    systemLayout->addWidget(pushButtonClose);
    QObject::connect(pushButtonClose, SIGNAL(clicked()), this, SLOT(pushButtonClose()));

    // Main panel layout
    QGridLayout* mainGridLayout = new QGridLayout();
    mainGridLayout->setSpacing(0);
    mainGridLayout->setMargin(0);
    setLayout(mainGridLayout);

    // Central widget
    QWidget* centralWidget = new QWidget(this);
    centralWidget->setObjectName("centralWidget");
    centralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // Main panel scroll area
    QScrollArea* scrollArea = new QScrollArea(this);
    scrollArea->setWidgetResizable(true);
    scrollArea->setObjectName("mainPanelScrollArea");
    scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    // Vertical layout example
    QVBoxLayout* verticalLayout = new QVBoxLayout();
    verticalLayout->setSpacing(5);
    verticalLayout->setMargin(0);
    verticalLayout->setAlignment(Qt::AlignHCenter);
    verticalLayout->addLayout(topLayout, 1);

    verticalLayout->addWidget(stack, 4);

    // Connect signals
    connect(libraryTab, SIGNAL(clicked()), this, SLOT(setTabLibrary()));
    connect(browserTab, SIGNAL(clicked()), this, SLOT(setTabBrowser()));

    // Show
    centralWidget->setLayout(verticalLayout);
    scrollArea->setWidget(centralWidget);
    mainGridLayout->addWidget(scrollArea);
}
Example #17
0
void MainWindow::initWidgets()
{
    tabwidget = new QTabWidget(this);

    QWidget *widget = new QWidget(this);

    QGridLayout *layout = new QGridLayout(widget);

    QScrollArea *areasettings = new QScrollArea(this);

#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(Q_OS_WINPHONE)
    areasettings->setWidgetResizable(true);
    areasettings->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
#endif

#ifndef Q_OS_ANDROID
    m_ffmpeg = new FFMPEGClass(this);
#endif

    m_ffmpeg_terminating = false;

    m_ffmpeg_playing = false;

    QWidget *widgetsettings = new QWidget(this);

    QGridLayout *layout1 = new QGridLayout(widgetsettings);

    comboboxaudioinput = new QComboBox(this);

    boxlisteninput = new QCheckBox(this);
    boxlisteninput->setText("Listen");

    listconnections = new QListWidget(this);

    lineport = new QLineEdit(this);

    linemaxconnections = new QLineEdit(this);

    linesamplerate = new QLineEdit(this);

    linechannels = new QLineEdit(this);

    buttonstart = new QPushButton(this);
    buttonstart->setText("Start Server");

    lineid = new QLineEdit(this);

    linepassword = new QLineEdit(this);
    linepassword->setEchoMode(QLineEdit::Password);

    labelvolume = new QLabel(this);
    slidervolume = new QSlider(Qt::Horizontal, this);

    slidervolume->setRange(0, 100);

    buttonstart->setDefault(true);

    texteditsettings = new QPlainTextEdit(this);

    layout1->addWidget(new QLabel("Input device:", this), 0, 0);
    layout1->addWidget(comboboxaudioinput, 0, 1);
    layout1->addWidget(boxlisteninput, 0, 2);
    layout1->addWidget(new QLabel("Port:", this), 1, 0);
    layout1->addWidget(lineport, 1, 1);
    layout1->addWidget(buttonstart, 1, 2);
    layout1->addWidget(new QLabel("Maximum connections:", this), 2, 0);
    layout1->addWidget(linemaxconnections, 2, 1, 1, 2);
    layout1->addWidget(new QLabel("ID:", this), 3, 0);
    layout1->addWidget(lineid, 3, 1, 1, 2);
    layout1->addWidget(new QLabel("Password:"******"Sample rate:", this), 5, 0);
    layout1->addWidget(linesamplerate, 5, 1, 1, 2);
    layout1->addWidget(new QLabel("Channels:", this), 6, 0);
    layout1->addWidget(linechannels, 6, 1, 1, 2);

    areasettings->setWidget(widgetsettings);

    bars = new BarsWidget(this);
    waveform = new WaveFormWidget(this);
    level = new LevelWidget(this);

    waveform->setMinimumHeight(10);
    waveform->setMaximumHeight(100);
    bars->setMinimumHeight(100);

    QWidget *analyzer = new QWidget(this);

    QGridLayout *layout_analyzer = new QGridLayout(analyzer);
    layout_analyzer->setMargin(0);
    layout_analyzer->addWidget(waveform, 0, 0);
    layout_analyzer->addWidget(bars, 1, 0);

    linerecordpath = new QLineEdit(this);
    buttonsearch = new QPushButton(this);
    buttonrecord = new QPushButton(this);
    buttonrecordstop = new QPushButton(this);
    lcdtime = new QLCDNumber(this);
    boxautostart = new QCheckBox("Auto start recording when server starts", this);

    QWidget *recorder = new QWidget(this);

    QGridLayout *layout_record = new QGridLayout(recorder);
    layout_record->addWidget(new QLabel("Audio file:", this), 0, 0);
    layout_record->addWidget(linerecordpath, 0, 1);
    layout_record->addWidget(buttonsearch, 0, 2);
    layout_record->addWidget(buttonrecord, 0, 3);
    layout_record->addWidget(buttonrecordstop, 0, 4);
    layout_record->addWidget(lcdtime, 1, 0, 1, 5);
    layout_record->addWidget(boxautostart, 2, 0, 1, 5);

    texteditlog = new QPlainTextEdit(this);
    texteditlog->setMaximumBlockCount(10000);
    debug_edit = texteditlog;

    tabwidget->addTab(areasettings," Settings");
#ifndef Q_OS_ANDROID
    tabwidget->addTab(m_ffmpeg, "FFMPEG");
#else
    tabwidget->addTab(new QWidget(this), "FFMPEG");
    tabwidget->setTabEnabled(1, false);
#endif
    tabwidget->addTab(analyzer, "Analyzer");
    tabwidget->addTab(listconnections, "Connections");
    tabwidget->addTab(recorder, "Record");
    tabwidget->addTab(texteditsettings, "Info");
    tabwidget->addTab(texteditlog, "Log");

    layout->addWidget(tabwidget, 0, 0, 1, 1);
    layout->addWidget(labelvolume, 1, 0, 1, 1);
    layout->addWidget(slidervolume, 2, 0, 1, 1);
    layout->addWidget(level, 0, 1, 3, 1);

    slidervolume->setEnabled(false);

    texteditsettings->setReadOnly(true);

    texteditlog->setReadOnly(true);

    connect(boxlisteninput, &QCheckBox::clicked, this, &MainWindow::boxListenInputClicked);

    connect(slidervolume, &QSlider::valueChanged, this, &MainWindow::volumeChanged);
    connect(lineport, &QLineEdit::returnPressed, this, &MainWindow::start);
    connect(linemaxconnections, &QLineEdit::returnPressed, this, &MainWindow::start);
    connect(lineid, &QLineEdit::returnPressed, this, &MainWindow::start);
    connect(linepassword, &QLineEdit::returnPressed, this, &MainWindow::start);
    connect(buttonstart, &QPushButton::clicked, this, &MainWindow::start);

    connect(buttonsearch, &QPushButton::clicked, this, &MainWindow::setRecordPath);
    connect(buttonrecord, &QPushButton::clicked, this, &MainWindow::startPauseRecord);
    connect(buttonrecordstop, &QPushButton::clicked, this, &MainWindow::stopRecord);

    resetRecordPage();

#ifndef Q_OS_ANDROID
    connect(m_ffmpeg, &FFMPEGClass::rawAudio, this, &MainWindow::ffmpegdata);

    connect(m_ffmpeg, &FFMPEGClass::mediaPlay, this, &MainWindow::ffmpegplay);

    connect(m_ffmpeg, &FFMPEGClass::mediaPause, this, &MainWindow::ffmpegpause);

    connect(m_ffmpeg, &FFMPEGClass::mediaStop, this, &MainWindow::ffmpegstop);

    connect(m_ffmpeg, &FFMPEGClass::allFinished, this, &MainWindow::ffmpegallfinished);
#endif

    lineport->setText("1024");
    linemaxconnections->setText("10");

    slidervolume->setValue(100);

    widgetsettings->setFixedHeight(widgetsettings->sizeHint().height());

    setCentralWidget(widget);

    getDevInfo();
}
Example #18
0
ProcessImage::ProcessImage( QWidget* parent ): DropArea(parent), _currentItem(-1), _currentImage(-1)
{
    layout = new QHBoxLayout( this );
    layout->setContentsMargins(0,0,0,0);
    layout->setSpacing(0);

    QFrame *processLeftColFrame = new QFrame();
    processLeftColFrame->setObjectName( "processLeftColFrame" );
    
    QVBoxLayout *leftLayout = new QVBoxLayout( processLeftColFrame );
    layout->addWidget( processLeftColFrame );

        QHBoxLayout *topLayout = new QHBoxLayout();

        topLayout->addWidget( backButton = new QPushButton( this ) );
        backButton->setText( "Choisir un autre media" );
        backButton->setObjectName("backButton");
        connect(backButton, SIGNAL(clicked()), SLOT(onBackButtonClicked()) );

        topLayout->addWidget( newSearch = new QPushButton( "Nouvelle recherche" ) );
        newSearch->setObjectName("newSearch");
        connect( newSearch, SIGNAL(clicked()), SLOT(onNewSearch()) );


        topLayout->addStretch(0);
        topLayout->addWidget( nbFacesLbl = new QLabel( this ) );
        nbFacesLbl->setObjectName( "nbFacesLbl" );


        /*
        overlap = new QLabel( this );
        overlap->setObjectName( "overlapLoader" );
        QMovie *loaderMovie = new QMovie(":/res/loader.gif");
        overlap->setMovie( loaderMovie );
        loaderMovie->start()
        */
        // overlap->setGeometry( imageLbl->geometry() );

        // topLayout->addWidget( overlap );

        leftLayout->addLayout( topLayout );



        leftLayout->addWidget( theater = new Theater( this ) );
        theater->imageOverlay->setOverlayText("Traitement en cours...");
        connect( theater, SIGNAL(rectClicked(int)), SLOT(onPersonSelected(int)) );
        


        QScrollArea *imagesScrollArea = new QScrollArea( this );
        leftLayout->addWidget( imagesScrollArea );

        imagesScrollArea->setWidgetResizable( true );
        imagesScrollArea->setObjectName( "imagesScrollArea" );
        imagesScrollArea->setWidget( showCase = new ShowCase( this ) );


        connect( showCase, SIGNAL(imageSelected(int)), SLOT(loadImageData(int)) );

    // COL 3
    layout->addWidget( sidePanel = new SidePanel(this, "view") );
    connect(sidePanel, SIGNAL(confirmChanges(QJsonObject)), SLOT(savePanelChanges(QJsonObject)) );

    connect( sidePanel, SIGNAL(confirmPerson()), SLOT( onConfirmPerson()) );
    connect( sidePanel, SIGNAL(refutePerson()), SLOT( onRefutePerson()) );



    //COL2
    QVBoxLayout* col2 = new QVBoxLayout();
    col2->setSpacing(0);

    col2->addWidget( detectedFacesScrollArea = new QScrollArea( this ) );
    detectedFacesScrollArea->setWidgetResizable( true );
    detectedFacesScrollArea->setObjectName( "detectedFacesScrollArea" );
    detectedFacesScrollArea->setWidget( detectedFaces = new DetectedFaces( this ) );
    
    layout->addLayout( col2 );
    connect( detectedFaces, SIGNAL(itemClicked(int)), SLOT(onPersonSelected(int)) );

    connect( &Socket::sock(), SIGNAL(faceRecognized(int, int, int, int, int, int)), SLOT(onFaceRecognized(int, int, int, int, int, int)) );
    connect( &Socket::sock(), SIGNAL(faceIs(int, QString, QString)), SLOT(onFaceIs(int, QString, QString)) );
    connect( &Socket::sock(), SIGNAL(got(QJsonObject, QByteArray)), sidePanel, SLOT(populate(QJsonObject, QByteArray)) );
}
Example #19
0
OSItemList::OSItemList(OSVectorController* vectorController,
                       bool addScrollArea,
                       QWidget * parent)
  : OSItemSelector(parent),
    m_vectorController(vectorController),
    m_vLayout(nullptr),
    m_selectedItem(nullptr),
    m_itemsDraggable(false),
    m_itemsRemoveable(false),
    m_type(OSItemType::ListItem),
    m_dirty(false)
{
  // for now we will allow this item list to manage memory of 
  OS_ASSERT(!m_vectorController->parent());
  m_vectorController->setParent(this);

  this->setObjectName("GrayWidget"); 

  QString style;

  style.append("QWidget#GrayWidget {");
  style.append(" background: #E6E6E6;");
  style.append(" border-bottom: 1px solid black;");
  style.append("}");

  setStyleSheet(style);

  QVBoxLayout* outerVLayout = new QVBoxLayout();
  outerVLayout->setContentsMargins(0,0,0,0);
  this->setLayout(outerVLayout);

  QWidget* outerWidget = new QWidget();

  if (addScrollArea){
    QScrollArea* scrollArea = new QScrollArea();
    scrollArea->setFrameStyle(QFrame::NoFrame);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    outerVLayout->addWidget(scrollArea);
    scrollArea->setWidget(outerWidget);
    scrollArea->setWidgetResizable(true);
  }else{
    outerVLayout->addWidget(outerWidget);
  }

  m_vLayout = new QVBoxLayout();
  outerWidget->setLayout(m_vLayout);
  m_vLayout->setContentsMargins(0,0,0,0);
  m_vLayout->setSpacing(0);
  m_vLayout->addStretch();

  connect(this, &OSItemList::itemsRequested, vectorController, &OSVectorController::reportItems);

  /* Vector controller does not handle removing items in list from model
  *
  connect(this, &OSItemList::itemRemoveClicked, vectorController, &OSVectorController::removeItem);
  */

  connect(vectorController, &OSVectorController::itemIds, this, &OSItemList::setItemIds);

  connect(vectorController, &OSVectorController::selectedItemId, this, &OSItemList::selectItemId);

  // allow time for OSDocument to finish constructing
  QTimer::singleShot(0, vectorController, SLOT(reportItems()));
}
PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags)  :
    QDesignerPropertyEditor(parent, flags),
    m_core(core),
    m_propertySheet(0),
    m_currentBrowser(0),
    m_treeBrowser(0),
    m_propertyManager(new DesignerPropertyManager(m_core, this)),
    m_dynamicGroup(0),
    m_updatingBrowser(false),
    m_stackedWidget(new QStackedWidget),
    m_filterWidget(new FilterWidget(0, FilterWidget::LayoutAlignNone)),
    m_buttonIndex(-1),
    m_treeIndex(-1),
    m_addDynamicAction(new QAction(createIconSet(QLatin1String("plus.png")), tr("Add Dynamic Property..."), this)),
    m_removeDynamicAction(new QAction(createIconSet(QLatin1String("minus.png")), tr("Remove Dynamic Property"), this)),
    m_sortingAction(new QAction(createIconSet(QLatin1String("sort.png")), tr("Sorting"), this)),
    m_coloringAction(new QAction(createIconSet(QLatin1String("color.png")), tr("Color Groups"), this)),
    m_treeAction(new QAction(tr("Tree View"), this)),
    m_buttonAction(new QAction(tr("Drop Down Button View"), this)),
    m_classLabel(new ElidingLabel),
    m_sorting(false),
    m_coloring(false),
    m_brightness(false)
{
    QVector<QColor> colors;
    colors.reserve(6);
    colors.push_back(QColor(255, 230, 191));
    colors.push_back(QColor(255, 255, 191));
    colors.push_back(QColor(191, 255, 191));
    colors.push_back(QColor(199, 255, 255));
    colors.push_back(QColor(234, 191, 255));
    colors.push_back(QColor(255, 191, 239));
    m_colors.reserve(colors.count());
    const int darknessFactor = 250;
    for (int i = 0; i < colors.count(); i++) {
        QColor c = colors.at(i);
        m_colors.push_back(qMakePair(c, c.darker(darknessFactor)));
    }
    QColor dynamicColor(191, 207, 255);
    QColor layoutColor(255, 191, 191);
    m_dynamicColor = qMakePair(dynamicColor, dynamicColor.darker(darknessFactor));
    m_layoutColor = qMakePair(layoutColor, layoutColor.darker(darknessFactor));

    updateForegroundBrightness();

    QActionGroup *actionGroup = new QActionGroup(this);

    m_treeAction->setCheckable(true);
    m_treeAction->setIcon(createIconSet(QLatin1String("widgets/listview.png")));
    m_buttonAction->setCheckable(true);
    m_buttonAction->setIcon(createIconSet(QLatin1String("dropdownbutton.png")));

    actionGroup->addAction(m_treeAction);
    actionGroup->addAction(m_buttonAction);
    connect(actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotViewTriggered(QAction*)));

    // Add actions
    QActionGroup *addDynamicActionGroup = new QActionGroup(this);
    connect(addDynamicActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotAddDynamicProperty(QAction*)));

    QMenu *addDynamicActionMenu = new QMenu(this);
    m_addDynamicAction->setMenu(addDynamicActionMenu);
    m_addDynamicAction->setEnabled(false);
    QAction *addDynamicAction = addDynamicActionGroup->addAction(tr("String..."));
    addDynamicAction->setData(static_cast<int>(QVariant::String));
    addDynamicActionMenu->addAction(addDynamicAction);
    addDynamicAction = addDynamicActionGroup->addAction(tr("Bool..."));
    addDynamicAction->setData(static_cast<int>(QVariant::Bool));
    addDynamicActionMenu->addAction(addDynamicAction);
    addDynamicActionMenu->addSeparator();
    addDynamicAction = addDynamicActionGroup->addAction(tr("Other..."));
    addDynamicAction->setData(static_cast<int>(QVariant::Invalid));
    addDynamicActionMenu->addAction(addDynamicAction);
    // remove
    m_removeDynamicAction->setEnabled(false);
    connect(m_removeDynamicAction, SIGNAL(triggered()), this, SLOT(slotRemoveDynamicProperty()));
    // Configure
    QAction *configureAction = new QAction(tr("Configure Property Editor"), this);
    configureAction->setIcon(createIconSet(QLatin1String("configure.png")));
    QMenu *configureMenu = new QMenu(this);
    configureAction->setMenu(configureMenu);

    m_sortingAction->setCheckable(true);
    connect(m_sortingAction, SIGNAL(toggled(bool)), this, SLOT(slotSorting(bool)));

    m_coloringAction->setCheckable(true);
    connect(m_coloringAction, SIGNAL(toggled(bool)), this, SLOT(slotColoring(bool)));

    configureMenu->addAction(m_sortingAction);
    configureMenu->addAction(m_coloringAction);
#if QT_VERSION >= 0x04FF00
    configureMenu->addSeparator();
    configureMenu->addAction(m_treeAction);
    configureMenu->addAction(m_buttonAction);
#endif
    // Assemble toolbar
    QToolBar *toolBar = new QToolBar;
    toolBar->addWidget(m_filterWidget);
    toolBar->addWidget(createDropDownButton(m_addDynamicAction));
    toolBar->addAction(m_removeDynamicAction);
    toolBar->addWidget(createDropDownButton(configureAction));
    // Views
    QScrollArea *buttonScroll = new QScrollArea(m_stackedWidget);
    m_buttonBrowser = new QtButtonPropertyBrowser(buttonScroll);
    buttonScroll->setWidgetResizable(true);
    buttonScroll->setWidget(m_buttonBrowser);
    m_buttonIndex = m_stackedWidget->addWidget(buttonScroll);
    connect(m_buttonBrowser, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentItemChanged(QtBrowserItem*)));

    m_treeBrowser = new QtTreePropertyBrowser(m_stackedWidget);
    m_treeBrowser->setRootIsDecorated(false);
    m_treeBrowser->setPropertiesWithoutValueMarked(true);
    m_treeBrowser->setResizeMode(QtTreePropertyBrowser::Interactive);
    m_treeIndex = m_stackedWidget->addWidget(m_treeBrowser);
    connect(m_treeBrowser, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentItemChanged(QtBrowserItem*)));
    connect(m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(setFilter(QString)));

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(toolBar);
    layout->addWidget(m_classLabel);
    layout->addSpacerItem(new QSpacerItem(0,1));
    layout->addWidget(m_stackedWidget);
    layout->setMargin(0);
    layout->setSpacing(0);

    m_treeFactory = new DesignerEditorFactory(m_core, this);
    m_treeFactory->setSpacing(0);
    m_groupFactory = new DesignerEditorFactory(m_core, this);
    QtVariantPropertyManager *variantManager = m_propertyManager;
    m_buttonBrowser->setFactoryForManager(variantManager, m_groupFactory);
    m_treeBrowser->setFactoryForManager(variantManager, m_treeFactory);

    m_stackedWidget->setCurrentIndex(m_treeIndex);
    m_currentBrowser = m_treeBrowser;
    m_treeAction->setChecked(true);

    connect(m_groupFactory, SIGNAL(resetProperty(QtProperty*)), this, SLOT(slotResetProperty(QtProperty*)));
    connect(m_treeFactory, SIGNAL(resetProperty(QtProperty*)), this, SLOT(slotResetProperty(QtProperty*)));
    connect(variantManager, SIGNAL(valueChanged(QtProperty*,QVariant,bool)), this, SLOT(slotValueChanged(QtProperty*,QVariant,bool)));

    // retrieve initial settings
    QDesignerSettingsInterface *settings = m_core->settingsManager();
    settings->beginGroup(QLatin1String(SettingsGroupC));
#if QT_VERSION >= 0x040500
    const SettingsView view = settings->value(QLatin1String(ViewKeyC), TreeView).toInt() == TreeView ? TreeView :  ButtonView;
#endif
    // Coloring not available unless treeview and not sorted
    m_sorting = settings->value(QLatin1String(SortedKeyC), false).toBool();
    m_coloring = settings->value(QLatin1String(ColorKeyC), true).toBool();
    const QVariantMap expansionState = settings->value(QLatin1String(ExpansionKeyC), QVariantMap()).toMap();
    settings->endGroup();
    // Apply settings
    m_sortingAction->setChecked(m_sorting);
    m_coloringAction->setChecked(m_coloring);
#if QT_VERSION >= 0x040500
    switch (view) {
    case TreeView:
        m_currentBrowser = m_treeBrowser;
        m_stackedWidget->setCurrentIndex(m_treeIndex);
        m_treeAction->setChecked(true);
        break;
    case ButtonView:
        m_currentBrowser = m_buttonBrowser;
        m_stackedWidget->setCurrentIndex(m_buttonIndex);
        m_buttonAction->setChecked(true);
        break;
    }
#endif
    // Restore expansionState from QVariant map
    if (!expansionState.empty()) {
        const QVariantMap::const_iterator cend = expansionState.constEnd();
        for (QVariantMap::const_iterator it = expansionState.constBegin(); it != cend; ++it)
            m_expansionState.insert(it.key(), it.value().toBool());
    }
    updateActionsState();
}
QWidget* QgsAttributeEditor::createWidgetFromDef( const QgsAttributeEditorElement* widgetDef, QWidget* parent, QgsVectorLayer* vl, QgsAttributeMap &attrs, QMap<int, QWidget*> &proxyWidgets, bool createGroupBox )
{
  QWidget *newWidget = 0;

  switch ( widgetDef->type() )
  {
    case QgsAttributeEditorElement::AeTypeField:
    {
      const QgsAttributeEditorField* fieldDef = dynamic_cast<const QgsAttributeEditorField*>( widgetDef );
      newWidget = createAttributeEditor( parent, 0, vl, fieldDef->idx(), attrs.value( fieldDef->idx(), QVariant() ), proxyWidgets );


      if ( vl->editType( fieldDef->idx() ) != QgsVectorLayer::Immutable )
      {
        newWidget->setEnabled( newWidget->isEnabled() && vl->isEditable() );
      }

      break;
    }

    case QgsAttributeEditorElement::AeTypeContainer:
    {
      const QgsAttributeEditorContainer* container = dynamic_cast<const QgsAttributeEditorContainer*>( widgetDef );
      QWidget* myContainer;

      if ( createGroupBox )
      {
        QGroupBox* groupBox = new QGroupBox( parent );
        groupBox->setTitle( container->name() );
        myContainer = groupBox;
        newWidget = myContainer;
      }
      else
      {
        QScrollArea *scrollArea = new QScrollArea( parent );

        myContainer = new QWidget( scrollArea );

        scrollArea->setWidget( myContainer );
        scrollArea->setWidgetResizable( true );
        scrollArea->setFrameShape( QFrame::NoFrame );

        newWidget = scrollArea;
      }

      QGridLayout* gbLayout = new QGridLayout( myContainer );
      myContainer->setLayout( gbLayout );

      int index = 0;

      QList<QgsAttributeEditorElement*>children = container->children();

      for ( QList<QgsAttributeEditorElement*>::const_iterator it = children.begin(); it != children.end(); ++it )
      {
        QgsAttributeEditorElement* childDef = *it;
        QWidget* editor = createWidgetFromDef( childDef, myContainer, vl, attrs, proxyWidgets, true );

        if ( childDef->type() == QgsAttributeEditorElement::AeTypeContainer )
        {
          gbLayout->addWidget( editor, index, 0, 1, 2 );
        }
        else
        {
          const QgsAttributeEditorField* fieldDef = dynamic_cast<const QgsAttributeEditorField*>( childDef );

          //show attribute alias if available
          QString myFieldName = vl->attributeDisplayName( fieldDef->idx() );
          QLabel * mypLabel = new QLabel( myContainer );
          gbLayout->addWidget( mypLabel, index, 0 );
          mypLabel->setText( myFieldName );

          // add editor widget
          gbLayout->addWidget( editor, index, 1 );
        }

        ++index;
      }
      gbLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ), index , 0 );

      break;
    }

    default:
      QgsDebugMsg( "Unknown attribute editor widget type encountered..." );
      break;
  }

  return newWidget;
}
Example #22
0
int main(int argc, char **argv)
{
    // Qt requires that we construct the global QApplication before creating any widgets.
    QApplication app(argc, argv);

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    // true = run osgViewer in a separate thread than Qt
    // false = interleave osgViewer and Qt in the main thread
    bool useFrameLoopThread = true;
    if (arguments.read("--noFrameThread")) useFrameLoopThread = false;

    // true = use QWidgetImage
    // false = use QWebViewImage
    bool useWidgetImage = false;
    if (arguments.read("--useWidgetImage")) useWidgetImage = true;

    // true = use QWebView in a QWidgetImage to compare to QWebViewImage
    // false = make an interesting widget
    bool useBrowser = false;
    if (arguments.read("--useBrowser")) useBrowser = true;

    // true = use a QLabel for text
    // false = use a QTextEdit for text
    // (only applies if useWidgetImage == true and useBrowser == false)
    bool useLabel = false;
    if (arguments.read("--useLabel")) useLabel = true;

    // true = make a Qt window with the same content to compare to 
    // QWebViewImage/QWidgetImage
    // false = use QWebViewImage/QWidgetImage (depending on useWidgetImage)
    bool sanityCheck = false;
    if (arguments.read("--sanityCheck")) sanityCheck = true;

    // Add n floating windows inside the QGraphicsScene.
    int numFloatingWindows = 0;
    while (arguments.read("--numFloatingWindows", numFloatingWindows));

    // true = Qt widgets will be displayed on a quad inside the 3D scene
    // false = Qt widgets will be an overlay over the scene (like a HUD)
    bool inScene = true;
    if (arguments.read("--fullscreen")) { inScene = false; }


    osg::ref_ptr<osg::Group> root = new osg::Group;

    if (!useWidgetImage)
    {
        //-------------------------------------------------------------------
        // QWebViewImage test
        //-------------------------------------------------------------------
        // Note: When the last few issues with QWidgetImage are fixed, 
        // QWebViewImage and this if() {} section can be removed since 
        // QWidgetImage can display a QWebView just like QWebViewImage. Use 
        // --useWidgetImage --useBrowser to see that in action.

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;

            if (arguments.argc()>1) image->navigateTo((arguments[1]));
            else image->navigateTo("http://www.youtube.com/");

            osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
                                           osg::Vec3(1.0f,0.0f,0.0f),
                                           osg::Vec3(0.0f,0.0f,1.0f),
                                           osg::Vec4(1.0f,1.0f,1.0f,1.0f),
                                           osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

            osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
            browser->assign(image.get(), hints);

            root->addChild(browser.get());
        }
        else
        {
            // Sanity check, do the same thing as QGraphicsViewAdapter but in 
            // a separate Qt window.
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.youtube.com/"));

            QGraphicsScene* graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(webView);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            //mainWindow->setLayout(new QVBoxLayout);
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }
    }
    else
    {
        //-------------------------------------------------------------------
        // QWidgetImage test
        //-------------------------------------------------------------------
        // QWidgetImage still has some issues, some examples are:
        // 
        // 1. Editing in the QTextEdit doesn't work. Also when started with 
        //    --useBrowser, editing in the search field on YouTube doesn't 
        //    work. But that same search field when using QWebViewImage 
        //    works... And editing in the text field in the pop-up getInteger 
        //    dialog works too. All these cases use QGraphicsViewAdapter 
        //    under the hood, so why do some work and others don't?
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen] (optional)
        //    b) Try to click in the QTextEdit and type, or to select text
        //       and drag-and-drop it somewhere else in the QTextEdit. These
        //       don't work.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operations in b), they all work.
        //    e) osgQtBrowser --useWidgetImage --useBrowser [--fullscreen]
        //    f) Try to click in the search field and type, it doesn't work.
        //    g) osgQtBrowser
        //    h) Try the operation in f), it works.
        //
        // 2. Operations on floating windows (--numFloatingWindows 1 or more). 
        //    Moving by dragging the titlebar, clicking the close button, 
        //    resizing them, none of these work. I wonder if it's because the 
        //    OS manages those functions (they're functions of the window 
        //    decorations) so we need to do something special for that? But 
        //    in --sanityCheck mode they work.
        //
        //    a) osgQtBrowser --useWidgetImage --numFloatingWindows 1 [--fullscreen]
        //    b) Try to drag the floating window, click the close button, or
        //       drag its sides to resize it. None of these work.
        //    c) osgQtBrowser --useWidgetImage --numFloatingWindows 1 --sanityCheck
        //    d) Try the operations in b), all they work.
        //    e) osgQtBrowser --useWidgetImage [--fullscreen]
        //    f) Click the button so that the getInteger() dialog is 
        //       displayed, then try to move that dialog or close it with the 
        //       close button, these don't work.
        //    g) osgQtBrowser --useWidgetImage --sanityCheck
        //    h) Try the operation in f), it works.
        //
        // 3. (Minor) The QGraphicsView's scrollbars don't appear when 
        //    using QWidgetImage or QWebViewImage. QGraphicsView is a 
        //    QAbstractScrollArea and it should display scrollbars as soon as
        //    the scene is too large to fit the view.
        //
        //    a) osgQtBrowser --useWidgetImage --fullscreen
        //    b) Resize the OSG window so it's smaller than the QTextEdit.
        //       Scrollbars should appear but don't.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operation in b), scrollbars appear. Even if you have 
        //       floating windows (by clicking the button or by adding 
        //       --numFloatingWindows 1) and move them outside the view, 
        //       scrollbars appear too. You can't test that case in OSG for 
        //       now because of problem 2 above, but that's pretty cool.
        //
        // 4. (Minor) In sanity check mode, the widget added to the 
        //    QGraphicsView is centered. With QGraphicsViewAdapter, it is not.
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen]
        //    b) The QTextEdit and button are not in the center of the image
        //       generated by the QGraphicsViewAdapter.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) The QTextEdit and button are in the center of the 
        //       QGraphicsView.


        QWidget* widget = 0;
        if (useBrowser)
        {
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.youtube.com/"));

            widget = webView;
        }
        else
        {
            widget = new QWidget;
            widget->setLayout(new QVBoxLayout);

            QString text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit turpis, euismod ac ultrices et, molestie non nisi. Nullam egestas dignissim enim, quis placerat nulla suscipit sed. Donec molestie elementum risus sit amet sodales. Nunc consectetur congue neque, at viverra massa pharetra fringilla. Integer vitae mi sem. Donec dapibus semper elit nec sollicitudin. Vivamus egestas ultricies felis, in mollis mi facilisis quis. Nam suscipit bibendum eros sed cursus. Suspendisse mollis suscipit hendrerit. Etiam magna eros, convallis non congue vel, faucibus ac augue. Integer ante ante, porta in ornare ullamcorper, congue nec nibh. Etiam congue enim vitae enim sollicitudin fringilla. Mauris mattis, urna in fringilla dapibus, ipsum sem feugiat purus, ac hendrerit felis arcu sed sapien. Integer id velit quam, sit amet dignissim tortor. Sed mi tortor, placerat ac luctus id, tincidunt et urna. Nulla sed nunc ante.Sed ut sodales enim. Ut sollicitudin ultricies magna, vel ultricies ante venenatis id. Cras luctus mi in lectus rhoncus malesuada. Sed ac sollicitudin nisi. Nunc venenatis congue quam, et suscipit diam consectetur id. Donec vel enim ac enim elementum bibendum ut quis augue. Nulla posuere suscipit dolor, id convallis tortor congue eu. Vivamus sagittis consectetur dictum. Duis a ante quis dui varius fermentum. In hac habitasse platea dictumst. Nam dapibus dolor eu felis eleifend in scelerisque dolor ultrices. Donec arcu lectus, fringilla ut interdum non, tristique id dolor. Morbi sagittis sagittis volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis venenatis ultrices euismod.Nam sit amet convallis libero. Integer lectus urna, eleifend et sollicitudin non, porttitor vel erat. Vestibulum pulvinar egestas leo, a porttitor turpis ullamcorper et. Vestibulum in ornare turpis. Ut nec libero a sem mattis iaculis quis id purus. Praesent ante neque, dictum vitae pretium vel, iaculis luctus dui. Etiam luctus tellus vel nunc suscipit a ullamcorper nisl semper. Nunc dapibus, eros in sodales dignissim, orci lectus egestas felis, sit amet vehicula tortor dolor eu quam. Vivamus pellentesque convallis quam aliquet pellentesque. Phasellus facilisis arcu ac orci fringilla aliquet. Donec sed euismod augue. Duis eget orci sit amet neque tempor fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst. Duis sollicitudin, lacus ac pellentesque lacinia, lacus magna pulvinar purus, pulvinar porttitor est nibh quis augue.Duis eleifend, massa sit amet mattis fringilla, elit turpis venenatis libero, sed convallis turpis diam sit amet ligula. Morbi non dictum turpis. Integer porttitor condimentum elit, sit amet sagittis nibh ultrices sit amet. Mauris ac arcu augue, id aliquet mauris. Donec ultricies urna id enim accumsan at pharetra dui adipiscing. Nunc luctus rutrum molestie. Curabitur libero ipsum, viverra at pulvinar ut, porttitor et neque. Aliquam sit amet dolor et purus sagittis adipiscing. Nam sit amet hendrerit sem. Etiam varius, ligula non ultricies dignissim, sapien dui commodo urna, eu vehicula enim nunc molestie augue. Fusce euismod, erat vitae pharetra tempor, quam eros tincidunt lorem, ut iaculis ligula erat vitae nibh. Aenean eu ultricies dolor. Curabitur suscipit viverra bibendum.Sed egestas adipiscing mi in egestas. Proin in neque in nibh blandit consequat nec quis tortor. Vestibulum sed interdum justo. Sed volutpat velit vitae elit pulvinar aliquam egestas elit rutrum. Proin lorem nibh, bibendum vitae sollicitudin condimentum, pulvinar ut turpis. Maecenas iaculis, mauris in consequat ultrices, ante erat blandit mi, vel fermentum lorem turpis eget sem. Integer ultrices tristique erat sit amet volutpat. In sit amet diam et nunc congue pellentesque at in dolor. Mauris eget orci orci. Integer posuere augue ornare tortor tempus elementum. Quisque iaculis, nunc ac cursus fringilla, magna elit cursus eros, id feugiat diam eros et tellus. Etiam consectetur ultrices erat quis rhoncus. Mauris eu lacinia neque. Curabitur suscipit feugiat tellus in dictum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed aliquam tempus ante a tempor. Praesent viverra erat quis sapien pretium rutrum. Praesent dictum scelerisque venenatis.Proin bibendum lectus eget nisl lacinia porta. Morbi eu erat in sapien malesuada vulputate. Cras non elit quam. Ut dictum urna quis nisl feugiat ac sollicitudin libero luctus. Donec leo mauris, varius at luctus eget, placerat quis arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam tristique, mauris ut lacinia elementum, mauris erat consequat massa, ac gravida nisi tellus vitae purus. Curabitur consectetur ultricies commodo. Cras pulvinar orci nec enim adipiscing tristique. Ut ornare orci id est fringilla sit amet blandit libero pellentesque. Vestibulum tincidunt sapien ut enim venenatis vestibulum ultricies ipsum tristique. Mauris tempus eleifend varius. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vitae dui ac quam gravida semper. In ac enim ac ligula rutrum porttitor.Integer dictum sagittis leo, at convallis sapien facilisis eget. Etiam cursus bibendum tortor, faucibus aliquam lectus ullamcorper sed. Nulla pulvinar posuere quam, ut sagittis ligula tincidunt ut. Nulla convallis velit ut enim condimentum pulvinar. Quisque gravida accumsan scelerisque. Proin pellentesque nisi cursus tortor aliquet dapibus. Duis vel eros orci. Sed eget purus ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ullamcorper porta congue. Nunc id velit ut neque malesuada consequat in eu nisi. Nulla facilisi. Quisque pellentesque magna vitae nisl euismod ac accumsan tellus feugiat.Nulla facilisi. Integer quis orci lectus, non aliquam nisi. Vivamus varius porta est, ac porttitor orci blandit mattis. Sed dapibus facilisis dapibus. Duis tincidunt leo ac tortor faucibus hendrerit. Morbi sit amet sapien risus, vel luctus enim. Aliquam sagittis nunc id purus aliquam lobortis. Duis posuere viverra dui, sit amet convallis sem vulputate at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque, lectus id imperdiet commodo, diam diam faucibus lectus, sit amet vestibulum tortor lacus viverra eros.Maecenas nec augue lectus. Duis nec arcu eget lorem tempus sollicitudin suscipit vitae arcu. Nullam vitae mauris lectus. Vivamus id risus neque, dignissim vehicula diam. Cras rhoncus velit sed velit iaculis ac dignissim turpis luctus. Suspendisse potenti. Sed vitae ligula a ligula ornare rutrum sit amet ut quam. Duis tincidunt, nibh vitae iaculis adipiscing, dolor orci cursus arcu, vel congue tortor quam eget arcu. Suspendisse tellus felis, blandit ac accumsan vitae, fringilla id lorem. Duis tempor lorem mollis est congue ut imperdiet velit laoreet. Nullam interdum cursus mollis. Pellentesque non mauris accumsan elit laoreet viverra ut at risus. Proin rutrum sollicitudin sem, vitae ultricies augue sagittis vel. Cras quis vehicula neque. Aliquam erat volutpat. Aliquam erat volutpat. Praesent non est erat, accumsan rutrum lacus. Pellentesque tristique molestie aliquet. Cras ullamcorper facilisis faucibus. In non lorem quis velit lobortis pulvinar.Phasellus non sem ipsum. Praesent ut libero quis turpis viverra semper. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Donec at velit tellus. Fusce commodo pharetra tincidunt. Proin lacus enim, fringilla a fermentum ut, vestibulum ut nibh. Duis commodo dolor vel felis vehicula at egestas neque bibendum. Phasellus malesuada dictum ante in aliquam. Curabitur interdum semper urna, nec placerat justo gravida in. Praesent quis mauris massa. Pellentesque porttitor lacinia tincidunt. Phasellus egestas viverra elit vel blandit. Sed dapibus nisi et lectus pharetra dignissim. Mauris hendrerit lectus nec purus dapibus condimentum. Sed ac eros nulla. Aenean semper sapien a nibh aliquam lobortis. Aliquam elementum euismod sapien, in dapibus leo dictum et. Pellentesque augue neque, ultricies non viverra eu, tincidunt ac arcu. Morbi ut porttitor lectus.");

            if (useLabel)
            {
                QLabel* label = new QLabel(text);
                label->setWordWrap(true);
                label->setTextInteractionFlags(Qt::TextEditorInteraction);

                QPalette palette = label->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                label->setPalette(palette);

                QScrollArea* scrollArea = new QScrollArea;
                scrollArea->setWidget(label);

                widget->layout()->addWidget(scrollArea);
            }
            else
            {
                QTextEdit* textEdit = new QTextEdit(text);
                textEdit->setReadOnly(false);
                textEdit->setTextInteractionFlags(Qt::TextEditable);

                QPalette palette = textEdit->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                textEdit->setPalette(palette);

                widget->layout()->addWidget(textEdit);
            }

            QPushButton* button = new MyPushButton("Button");
            widget->layout()->addWidget(button);

            widget->setGeometry(0, 0, 800, 600);
        }

        QGraphicsScene* graphicsScene = 0;

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWidgetImage> widgetImage = new osgQt::QWidgetImage(widget);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
            widgetImage->getQWidget()->setAttribute(Qt::WA_TranslucentBackground);
#endif
            widgetImage->getQGraphicsViewAdapter()->setBackgroundColor(QColor(0, 0, 0, 0));
            //widgetImage->getQGraphicsViewAdapter()->resize(800, 600);
            graphicsScene = widgetImage->getQGraphicsViewAdapter()->getQGraphicsScene();

            osg::Camera* camera = 0;        // Will stay NULL in the inScene case.
            osg::Geometry* quad = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0), osg::Vec3(1,0,0), osg::Vec3(0,1,0), 1, 1);
            osg::Geode* geode = new osg::Geode;
            geode->addDrawable(quad);

            osg::MatrixTransform* mt = new osg::MatrixTransform;
            if (inScene)
            {
                mt->setMatrix(osg::Matrix::rotate(osg::Vec3(0,1,0), osg::Vec3(0,0,1)));
                mt->addChild(geode);
            }
            else    // fullscreen
            {
                // The HUD camera's viewport needs to follow the size of the 
                // window. MyInteractiveImageHandler will make sure of this.
                // As for the quad and the camera's projection, setting the 
                // projection resize policy to FIXED takes care of them, so
                // they can stay the same: (0,1,0,1) with a quad that fits.

                // Set the HUD camera's projection and viewport to match the screen.
                camera = new osg::Camera;
                camera->setProjectionResizePolicy(osg::Camera::FIXED);
                camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
                camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
                camera->setViewMatrix(osg::Matrix::identity());
                camera->setClearMask(GL_DEPTH_BUFFER_BIT);
                camera->setRenderOrder(osg::Camera::POST_RENDER);
                camera->addChild(geode);
                camera->setViewport(0, 0, 1024, 768);

                mt->addChild(camera);
            }

            mt->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
            mt->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
            mt->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
            mt->getOrCreateStateSet()->setAttribute(new osg::Program);

            osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
            texture->setResizeNonPowerOfTwoHint(false);
            texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
            texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
            texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
            mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);

            osg::Group* overlay = new osg::Group;
            overlay->addChild(mt);

            root->addChild(overlay);

            osgViewer::InteractiveImageHandler* handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), texture, camera);
            quad->setEventCallback(handler);
            quad->setCullCallback(handler);
        }
        else
        {
            // Sanity check, do the same thing as QWidgetImage and 
            // QGraphicsViewAdapter but in a separate Qt window.

            graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(widget);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }

        // Add numFloatingWindows windows to the graphicsScene.
        for (unsigned int i = 0; i < (unsigned int)numFloatingWindows; ++i)
        {
            QWidget* window = new QWidget(0, Qt::Window);
            window->setWindowTitle(QString("Window %1").arg(i));
            window->setLayout(new QVBoxLayout);
            window->layout()->addWidget(new QLabel(QString("This window %1").arg(i)));
            window->layout()->addWidget(new MyPushButton(QString("Button in window %1").arg(i)));
            window->setGeometry(100, 100, 300, 300);

            QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window);
            proxy->setWidget(window);
            proxy->setFlag(QGraphicsItem::ItemIsMovable, true);

            graphicsScene->addItem(proxy);
        }

    }

    root->addChild(osgDB::readNodeFile("cow.osg.(15,0,5).trans.(0.1,0.1,0.1).scale"));

    osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(arguments);
    viewer->setSceneData(root.get());
    viewer->setCameraManipulator(new osgGA::TrackballManipulator());
    viewer->addEventHandler(new osgGA::StateSetManipulator(root->getOrCreateStateSet()));
    viewer->addEventHandler(new osgViewer::StatsHandler);
    viewer->addEventHandler(new osgViewer::WindowSizeHandler);

    viewer->setUpViewInWindow(50, 50, 1024, 768);
    viewer->getEventQueue()->windowResize(0, 0, 1024, 768);

    if (useFrameLoopThread)
    {
        // create a thread to run the viewer's frame loop
        ViewerFrameThread viewerThread(viewer.get(), true);
        viewerThread.startThread();

        // now start the standard Qt event loop, then exists when the viewerThead sends the QApplication::exit() signal.
        return QApplication::exec();

    }
    else
    {
        // run the frame loop, interleaving Qt and the main OSG frame loop
        while(!viewer->done())
        {
            // process Qt events - this handles both events and paints the browser image
            QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

            viewer->frame();
        }

        return 0;
    }
}
Example #23
0
/*public*/ CatalogPane::CatalogPane(QWidget* parent) :QWidget(parent) {

    //super(true); // isDoubleBuffered???
 log->setDebugEnabled(true);
    preview = new QLabel();
    preview->setMinimumSize(50,50);

    // create basic GUI
    dTree = new JTree((CatalogTreeModel*)InstanceManager::getDefault("CatalogTreeModel"));
    QVBoxLayout* thisLayout;
    setLayout(thisLayout = new QVBoxLayout(this)); //, BoxLayout.Y_AXIS));

    // build the tree GUI
    //add(new JScrollPane(dTree));
    thisLayout->addWidget(dTree);
    dTree->setRootVisible(true);
    dTree->setShowsRootHandles(true);
    //dTree.setScrollsOnExpand(true);
    dTree->setExpandsSelectedPaths(true);
    dTree->setHeaderHidden(true);
    dTree->setRootIsDecorated(true);

    dTree->getSelectionModel()->setSelectionMode(DefaultTreeSelectionModel::SINGLE_TREE_SELECTION);

    dTree->addTreeSelectionListener(new CPTreeSelectionListener(this));
//    {
//        @Override
//        /*public*/ void valueChanged(TreeSelectionEvent e) {
//            if (!dTree.isSelectionEmpty() && dTree.getSelectionPath() != null) {
//                // somebody has been selected
//                preview.setIcon(getSelectedIcon());
//            } else {
//                preview.setIcon(null);
//            }
//        }
//    });

    // add a listener for debugging
    if (log->isDebugEnabled())
    {
        dTree->addTreeSelectionListener(new CP2TreeSelectionListener(this));
//        {
//            @Override
//            /*public*/ void valueChanged(TreeSelectionEvent e) {
//                if (!dTree.isSelectionEmpty() && dTree.getSelectionPath() != null) {
//                    // somebody has been selected
//                    log->debug("Selection event with {}", dTree.getSelectionPath());
//                    log->debug("          icon: {}", getSelectedIcon());
//                }
//            }
//        });
    }
    qDebug() <<"catalog root child count: " << ((DefaultMutableTreeNode*)((CatalogTreeModel*)dTree->model())->getRoot())->getChildCount();
    //dTree->expandAll();
    QWidget* previewPanel = new QWidget();
    //previewPanel.setLayout(new BoxLayout(previewPanel, BoxLayout.X_AXIS));
    QHBoxLayout* previewPanelLayout = new QHBoxLayout(previewPanel);
    previewPanelLayout->addWidget(new QLabel(tr("File Preview")));
    QScrollArea* js = new QScrollArea();//JScrollPane(preview);
    js->setWidget(preview);
    previewPanelLayout->addWidget(js);
    thisLayout->addWidget(previewPanel);
}
PinLabelDialog::PinLabelDialog(const QStringList & labels, bool singleRow, const QString & chipLabel, bool isCore, QWidget *parent)
	: QDialog(parent)
{
	m_isCore = isCore;
	m_labels = labels;
	m_doSaveAs = true;
	this->setWindowTitle(QObject::tr("Pin Label Editor"));

	QVBoxLayout * vLayout = new QVBoxLayout(this);

	QScrollArea * scrollArea = new QScrollArea(this);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	QFrame * frame = new QFrame(this);
	QHBoxLayout * hLayout = new QHBoxLayout(frame);

	QFrame * labelsFrame = initLabels(labels, singleRow, chipLabel);

	QFrame * textFrame = new QFrame();
	QVBoxLayout * textLayout = new QVBoxLayout(frame);

	QLabel * label = new QLabel("<html><body>" +
								tr("<p><h2>Pin Label Editor</h2></p>") +
								tr("<p>Click on a label next to a pin number to rename that pin.") + " " +
								tr("You can use the tab key to move through the labels in order.</p>") +
								"</body></html>");
	label->setMaximumWidth(150);
	label->setWordWrap(true);

	textLayout->addWidget(label);
	textLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
	textFrame->setLayout(textLayout);

	hLayout->addWidget(labelsFrame);
	hLayout->addSpacing(15);
	hLayout->addWidget(textFrame);
	frame->setLayout(hLayout);

	scrollArea->setWidget(frame);	

	QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
	
	QPushButton * cancelButton = buttonBox->button(QDialogButtonBox::Cancel);
	cancelButton->setText(tr("Cancel"));
	cancelButton->setDefault(false);
	
	m_saveAsButton = buttonBox->button(QDialogButtonBox::Save);
	m_saveAsButton->setText(tr("Save"));
	m_saveAsButton->setEnabled(false);
	m_saveAsButton->setDefault(false);

	m_undoButton = new QPushButton(tr("Undo"));
	m_undoButton->setEnabled(false);
	m_undoButton->setDefault(false);

	m_redoButton = new QPushButton(tr("Redo"));
	m_redoButton->setEnabled(false);
	m_redoButton->setDefault(false);

    buttonBox->addButton(m_undoButton, QDialogButtonBox::ResetRole);
    buttonBox->addButton(m_redoButton, QDialogButtonBox::ResetRole);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

	vLayout->addWidget(scrollArea);
	vLayout->addWidget(buttonBox);
	this->setLayout(vLayout);

	connect(buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
	connect(&m_undoStack, SIGNAL(canRedoChanged(bool)), this, SLOT(undoChanged(bool)));
	connect(&m_undoStack, SIGNAL(canUndoChanged(bool)), this, SLOT(undoChanged(bool)));
	connect(&m_undoStack, SIGNAL(cleanChanged(bool)), this, SLOT(undoChanged(bool)));

}
Example #25
0
/**
 * Populate this dialog with the appropriate field editor widgets for the
 * database's columns, and set them to match the data in the specified row.
 *
 * @param rowId The data row to be edited or copied
 */
void RowEditor::addContent(int rowId)
{
    QScrollArea *sa = new QScrollArea(this);
    vbox->addWidget(sa);
    QWidget *grid = new QWidget();
    sa->setWidgetResizable(true);
    colNames = db->listColumns();
    int count = colNames.count();
    QGridLayout *layout = Factory::gridLayout(grid, true);
    QStringList values;
    if (rowId != -1) {
        values = db->getRow(rowId);
    }
    else {
        for (int i = 0; i < count; i++) {
            values.append(db->getDefault(colNames[i]));
        }
    }
    initialFocus = 0;
    colTypes = db->listTypes();
    for (int i = 0; i < count; i++) {
        QString name = colNames[i];
        int type = colTypes[i];
        layout->addWidget(new QLabel(name + " ", grid), i, 0);
        if (type == BOOLEAN) {
            QCheckBox *box = new QCheckBox(grid);
            layout->addWidget(box, i, 1);
            if (values[i].toInt()) {
                box->setChecked(true);
            }
            checkBoxes.append(box);
        }
        else if (type == INTEGER || type == FLOAT) {
            NumberWidget *widget = new NumberWidget(type, grid);
            layout->addWidget(widget, i, 1);
            widget->setValue(values[i]);
            numberWidgets.append(widget);
            if (!initialFocus) {
                initialFocus = widget;
            }
        }
        else if (type == NOTE) {
            NoteButton *button = new NoteButton(name, grid);
            layout->addWidget(button, i, 1);
            button->setContent(values[i]);
            noteButtons.append(button);
        }
        else if (type == DATE) {
            DateWidget *widget = new DateWidget(grid);
            layout->addWidget(widget, i, 1);
            widget->setDate(values[i].toInt());
            dateWidgets.append(widget);
        }
        else if (type == TIME) {
            TimeWidget *widget = new TimeWidget(grid);
            layout->addWidget(widget, i, 1);
            int defaultTime = values[i].toInt();
            if (defaultTime == 0) {
                defaultTime = -2;
            }
            widget->setTime(defaultTime);
            timeWidgets.append(widget);
        }
        else if (type == CALC) {
            CalcWidget *widget = new CalcWidget(db, name, colNames, this, grid);
            layout->addWidget(widget, i, 1);
            widget->setValue(values[i]);
            calcWidgets.append(widget);
        }
        else if (type == SEQUENCE) {
            QLabel *label = new QLabel(values[i], grid);
            layout->addWidget(label, i, 1);
            sequenceLabels.append(label);
        }
        else if (type == IMAGE) {
            ImageSelector *widget = new ImageSelector(db, grid);
            layout->addWidget(widget, i, 1);
            widget->setField(rowId, name);
            widget->setFormat(values[i]);
            imageSelectors.append(widget);
        }
        else if (type >= FIRST_ENUM) {
            QComboBox *combo = new QComboBox(grid);
            layout->addWidget(combo, i, 1);
            QStringList options = db->listEnumOptions(type);
            combo->addItems(options);
            int index = options.indexOf(values[i]);
            combo->setCurrentIndex(index);
            comboBoxes.append(combo);
        }
        else {
            DynamicEdit *edit = new DynamicEdit(grid);
            layout->addWidget(edit, i, 1);
            edit->setPlainText(values[i]);
            dynamicEdits.append(edit);
            if (!initialFocus) {
                initialFocus = edit;
            }
        }
    }
    layout->addWidget(new QWidget(grid), count, 0, 1, 2);
    layout->setRowStretch(count, 1);
    sa->setWidget(grid);

    finishLayout(true, true, 400, 400);
}
PackageDialog::PackageDialog(QWidget *parent_, bool create_)
    : QDialog(parent_) //, 0, TRUE, Qt::WDestructiveClose)
{
    all = new QVBoxLayout(this);
    all->setMargin(5);
    all->setSpacing(6);

    QHBoxLayout *h2 = new QHBoxLayout();

    if(create_) {  // create or extract package ?
        setWindowTitle(tr("Create Project Package"));

        QHBoxLayout *h1 = new QHBoxLayout();
        all->addLayout(h1);
        QLabel *packLabel = new QLabel(tr("Package:"));
        NameEdit = new QLineEdit();
        QPushButton *ButtBrowse = new QPushButton(tr("Browse"));
        connect(ButtBrowse, SIGNAL(clicked()), SLOT(slotBrowse()));
        h1->addWidget(packLabel);
        h1->addWidget(NameEdit);
        h1->addWidget(ButtBrowse);

        LibraryCheck = new QCheckBox(tr("include user libraries"));
        all->addWidget(LibraryCheck);

        Group = new QGroupBox(tr("Choose projects:"));
        all->addWidget(Group);

        QScrollArea *scrollArea = new QScrollArea(Group);
        scrollArea->setWidgetResizable(true);

        QWidget *scrollWidget = new QWidget();

        QVBoxLayout *checkBoxLayout = new QVBoxLayout();
        scrollWidget->setLayout(checkBoxLayout);
        scrollArea->setWidget(scrollWidget);

        QVBoxLayout *areaLayout = new QVBoxLayout();
        areaLayout->addWidget(scrollArea);
        Group->setLayout(areaLayout);

        // ...........................................................
        all->addLayout(h2);
        QPushButton *ButtCreate = new QPushButton(tr("Create"));
        h2->addWidget(ButtCreate);
        connect(ButtCreate, SIGNAL(clicked()), SLOT(slotCreate()));
        QPushButton *ButtCancel = new QPushButton(tr("Cancel"));
        h2->addWidget(ButtCancel);
        connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));

        // ...........................................................
        // insert all projects
        QStringList PrDirs = QucsHomeDir.entryList("*", QDir::Dirs, QDir::Name);
        QStringList::iterator it;
        for(it = PrDirs.begin(); it != PrDirs.end(); it++)
            if((*it).right(4) == "_prj") {  // project directories end with "_prj"
                QCheckBox *subCheck = new QCheckBox((*it).left((*it).length()-4));
                checkBoxLayout->addWidget(subCheck);
                BoxList.append(subCheck);
            }

        //QColor theColor;
        if(BoxList.isEmpty()) {
            ButtCreate->setEnabled(false);
            //theColor =
            //   (new QLabel(tr("No projects!"), Dia_Box))->paletteBackgroundColor();
            QLabel *noProj = new QLabel(tr("No projects!"));
            checkBoxLayout->addWidget(noProj);
        }
        //else
        //  theColor = BoxList.current()->paletteBackgroundColor();
        //Dia_Scroll->viewport()->setPaletteBackgroundColor(theColor);
    }

    else {  // of "if(create_)"
        setWindowTitle(tr("Extract Project Package"));

        MsgText = new QTextEdit(this);
        MsgText->setTextFormat(Qt::PlainText);
        MsgText->setWordWrapMode(QTextOption::NoWrap);
        MsgText->setReadOnly(true);
        all->addWidget(MsgText);

        all->addLayout(h2);
        h2->addStretch(5);
        ButtClose = new QPushButton(tr("Close"));
        h2->addWidget(ButtClose);
        ButtClose->setDisabled(true);
        connect(ButtClose, SIGNAL(clicked()), SLOT(accept()));

        resize(400, 250);
    }
}
Example #27
0
TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* parent )
    : QWidget( parent )
    , ui( new Ui::TrackInfoWidget )
{
    QWidget* widget = new QWidget;
    ui->setupUi( widget );

    QPalette pal = palette();
    pal.setColor( QPalette::Window, QColor( "#454e59" ) );

    widget->setPalette( pal );
    widget->setAutoFillBackground( true );
    ui->rightBar->setPalette( pal );
    ui->rightBar->setAutoFillBackground( true );

    ui->statsLabel->setStyleSheet( "QLabel { background-image:url(); border: 2px solid #dddddd; background-color: #faf9f9; border-radius: 4px; padding: 12px; }" );
    ui->lyricsView->setStyleSheet( "QTextBrowser#lyricsView { background-color: transparent; }" );

    ui->lyricsView->setFrameShape( QFrame::NoFrame );
    ui->lyricsView->setAttribute( Qt::WA_MacShowFocusRect, 0 );

    ui->similarTracksView->setAutoResize( true );
    ui->similarTracksView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
//    TomahawkUtils::styleScrollBar( ui->similarTracksView->verticalScrollBar() );
    TomahawkUtils::styleScrollBar( ui->lyricsView->verticalScrollBar() );

    QFont f = font();
    f.setBold( true );
    f.setPixelSize( 18 );
    ui->trackLabel->setFont( f );
//    ui->similarTracksLabel->setFont( f );

    f.setPixelSize( 14 );
    ui->artistLabel->setFont( f );
    ui->albumLabel->setFont( f );

    f.setPixelSize( 12 );
    ui->statsLabel->setFont( f );

//    ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" );

    QPalette p = ui->trackLabel->palette();
    p.setColor( QPalette::Foreground, Qt::white );
    p.setColor( QPalette::Text, Qt::white );

    ui->trackLabel->setPalette( p );
    ui->artistLabel->setPalette( p );
    ui->albumLabel->setPalette( p );
    ui->lyricsView->setPalette( p );
    ui->label->setPalette( p );
//    ui->similarTracksLabel->setPalette( p );

    ui->artistLabel->setType( QueryLabel::Artist );
    ui->albumLabel->setType( QueryLabel::Album );

    m_relatedTracksModel = new PlayableModel( ui->similarTracksView );
    ui->similarTracksView->setPlayableModel( m_relatedTracksModel );
    ui->similarTracksView->proxyModel()->sort( -1 );
    ui->similarTracksView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) );

    m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
    ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) );

    QScrollArea* area = new QScrollArea();
    area->setWidgetResizable( true );
    area->setWidget( widget );
    area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );

    area->setStyleSheet( "QScrollArea { background-color: #454e59 }" );
    area->setFrameShape( QFrame::NoFrame );
    area->setAttribute( Qt::WA_MacShowFocusRect, 0 );

    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget( area );
    setLayout( layout );
    TomahawkUtils::unmarginLayout( layout );

    ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; }" );
    ui->frame->setStyleSheet( "QFrame#frame { background-color: transparent; }"
                              "QFrame#frame { "
                              "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;"
                              "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" );

    load( query );

    connect( ui->artistLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
    connect( ui->albumLabel,  SIGNAL( clickedAlbum() ),  SLOT( onAlbumClicked() ) );
}
SettingsPageUnits::SettingsPageUnits(QWidget *parent) : QWidget(parent)
{
  setObjectName("SettingsPageUnits");
  setWindowFlags( Qt::Tool );
  setWindowModality( Qt::WindowModal );
  setAttribute(Qt::WA_DeleteOnClose);
  setWindowTitle( tr("Settings - Units") );

  if( parent )
    {
      resize( parent->size() );
    }

  // Layout used by scroll area
  QHBoxLayout *sal = new QHBoxLayout;

  // new widget used as container for the dialog layout.
  QWidget* sw = new QWidget;

  // Scroll area
  QScrollArea* sa = new QScrollArea;
  sa->setWidgetResizable( true );
  sa->setFrameStyle( QFrame::NoFrame );
  sa->setWidget( sw );

#ifdef ANDROID
  QScrollBar* lvsb = sa->verticalScrollBar();
  lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif

#ifdef QSCROLLER
  QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture );
#endif

#ifdef QTSCROLLER
  QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture );
#endif

  // Add scroll area to its own layout
  sal->addWidget( sa );

  QHBoxLayout *contentLayout = new QHBoxLayout;
  setLayout(contentLayout);

  // Pass scroll area layout to the content layout.
  contentLayout->addLayout( sal, 10 );

  // The parent of the layout is the scroll widget
  QGridLayout *topLayout = new QGridLayout(sw);

  int row=0;

  QLabel *label = new QLabel(tr("Altitude:"), this);
  topLayout->addWidget(label, row, 0);
  UnitAlt = new QComboBox(this);
  UnitAlt->setObjectName("UnitAlt");
  UnitAlt->setEditable(false);
  topLayout->addWidget(UnitAlt,row++,1);
  UnitAlt->addItem(tr("meters"));
  UnitAlt->addItem(tr("feet"));
  altitudes[0] = int(Altitude::meters);
  altitudes[1] = int(Altitude::feet);

  label = new QLabel(tr("Speed:"), this);
  topLayout->addWidget(label, row, 0);
  UnitSpeed = new QComboBox(this);
  UnitSpeed->setObjectName("UnitSpeed");
  UnitSpeed->setEditable(false);
  topLayout->addWidget(UnitSpeed,row++,1);
  UnitSpeed->addItem(tr("meters per second"));
  UnitSpeed->addItem(tr("kilometers per hour"));
  UnitSpeed->addItem(tr("knots"));
  UnitSpeed->addItem(tr("miles per hour"));
  speeds[0] = Speed::metersPerSecond;
  speeds[1] = Speed::kilometersPerHour;
  speeds[2] = Speed::knots;
  speeds[3] = Speed::milesPerHour;

  label = new QLabel(tr("Distance:"), this);
  topLayout->addWidget(label, row, 0);
  UnitDistance = new QComboBox(this);
  UnitDistance->setObjectName("UnitDistance");
  UnitDistance->setEditable(false);
  topLayout->addWidget(UnitDistance,row++,1);
  UnitDistance->addItem(tr("kilometers"));
  UnitDistance->addItem(tr("statute miles"));
  UnitDistance->addItem(tr("nautical miles"));
  distances[0] = Distance::kilometers;
  distances[1] = Distance::miles;
  distances[2] = Distance::nautmiles;

  label = new QLabel(tr("Vario:"), this);
  topLayout->addWidget(label, row, 0);
  UnitVario = new QComboBox(this);
  UnitVario->setObjectName("UnitVario");
  UnitVario->setEditable(false);
  topLayout->addWidget(UnitVario,row++,1);
  UnitVario->addItem(tr("meters per second"));
  UnitVario->addItem(tr("feet per minute"));
  UnitVario->addItem(tr("knots"));
  varios[0] = Speed::metersPerSecond;
  varios[1] = Speed::feetPerMinute;
  varios[2] = Speed::knots;

  label = new QLabel(tr("Wind:"), this);
  topLayout->addWidget(label, row, 0);
  UnitWind = new QComboBox(this);
  UnitWind->setObjectName("UnitWind");
  UnitWind->setEditable(false);
  topLayout->addWidget(UnitWind,row++,1);
  UnitWind->addItem(tr("meters per second"));
  UnitWind->addItem(tr("kilometers per hour"));
  UnitWind->addItem(tr("knots"));
  UnitWind->addItem(tr("miles per hour"));
  winds[0] = Speed::metersPerSecond;
  winds[1] = Speed::kilometersPerHour;
  winds[2] = Speed::knots;
  winds[3] = Speed::milesPerHour;

  label = new QLabel(tr("Position:"), this);
  topLayout->addWidget(label, row, 0);
  UnitPosition = new QComboBox(this);
  UnitPosition->setObjectName("UnitPosition");
  UnitPosition->setEditable(false);
  topLayout->addWidget(UnitPosition,row++,1);
  UnitPosition->addItem(QString("ddd") + Qt::Key_degree + "mm'ss\"");
  UnitPosition->addItem(QString("ddd") + Qt::Key_degree + "mm.mmm'");
  UnitPosition->addItem(QString("ddd.ddddd") + Qt::Key_degree);
  positions[0] = WGSPoint::DMS;
  positions[1] = WGSPoint::DDM;
  positions[2] = WGSPoint::DDD;

  label = new QLabel(tr("Time:"), this);
  topLayout->addWidget(label, row, 0);
  UnitTime = new QComboBox(this);
  UnitTime->setObjectName("UnitTime");
  UnitTime->setEditable(false);
  topLayout->addWidget(UnitTime,row++,1);
  UnitTime->addItem(tr("UTC"));
  UnitTime->addItem(tr("Local"));
  times[0] = Time::utc;
  times[1] = Time::local;

  label = new QLabel(tr("Temperature:"), this);
  topLayout->addWidget(label, row, 0);
  UnitTemperature = new QComboBox(this);
  UnitTemperature->setObjectName("UnitTemperature");
  UnitTemperature->setEditable(false);
  topLayout->addWidget(UnitTemperature,row++,1);
  UnitTemperature->addItem(tr("Celsius"));
  UnitTemperature->addItem(tr("Fahrenheit"));
  temperature[0] = GeneralConfig::Celsius;
  temperature[1] = GeneralConfig::Fahrenheit;

  label = new QLabel(tr("Air Pressure:"), this);
  topLayout->addWidget(label, row, 0);
  UnitAirPressure = new QComboBox(this);
  UnitAirPressure->setObjectName("UnitAirPressure");
  UnitAirPressure->setEditable(false);
  topLayout->addWidget(UnitAirPressure,row++,1);
  UnitAirPressure->addItem(tr("hPa"));
  UnitAirPressure->addItem(tr("inHg"));
  airPressure[0] = GeneralConfig::hPa;
  airPressure[1] = GeneralConfig::inHg;

  topLayout->setRowStretch(row++, 10);
  topLayout->setColumnStretch(2, 10);

  QPushButton *help = new QPushButton(this);
  help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png")));
  help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
  help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);

  QPushButton *cancel = new QPushButton(this);
  cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png")));
  cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
  cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);

  QPushButton *ok = new QPushButton(this);
  ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png")));
  ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
  ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);

  QLabel *titlePix = new QLabel(this);
  titlePix->setAlignment( Qt::AlignCenter );
  titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png"));

  connect(help, SIGNAL(pressed()), this, SLOT(slotHelp()));
  connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept()));
  connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject()));

  QVBoxLayout *buttonBox = new QVBoxLayout;
  buttonBox->setSpacing(0);
  buttonBox->addWidget(help, 1);
  buttonBox->addStretch(2);
  buttonBox->addWidget(cancel, 1);
  buttonBox->addSpacing(30);
  buttonBox->addWidget(ok, 1);
  buttonBox->addStretch(2);
  buttonBox->addWidget(titlePix);
  contentLayout->addLayout(buttonBox);

  load();
}
CloseGeometryDialog::CloseGeometryDialog(QWidget *parent,Qt::WFlags flags) 
  : QDialog(parent, flags)
{
  static log4cplus::Logger logger =
      log4cplus::Logger::getInstance("CloseGeometryDialog.CloseGeometryDialog");

  verticalLayout = new QVBoxLayout(this);
  verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));

  // check boxes
  QGridLayout* gridLayout = new QGridLayout();
  gridLayout->setSizeConstraint(QLayout::SetMinimumSize);

  QScrollArea* scrollArea = new QScrollArea();
  QWidget* w = new QWidget();
  w->setLayout(gridLayout);
  scrollArea->setWidget(w);
  verticalLayout->addWidget(scrollArea);

  // check all buttons
  QPushButton* selectAll = new QPushButton("Select all");
  QPushButton* unselectAll = new QPushButton("Unselect all");
  connect(selectAll, SIGNAL(clicked()), SLOT(selectAllSlot()));
  connect(unselectAll, SIGNAL(clicked()), SLOT(unselectAllSlot()));
  QHBoxLayout* selectLayout = new QHBoxLayout();
  selectLayout->addWidget(selectAll);
  selectLayout->addWidget(unselectAll);
  verticalLayout->addLayout(selectLayout);

  // output directory
  // _outputDir = new QLineEdit();
  // _outputDir->setText(".");
  // QPushButton* outputDirButton = new QPushButton("...");
  // connect(outputDirButton, SIGNAL(clicked()), SLOT(outputDirSlot()));
  // QGridLayout* dirLayout = new QGridLayout();
  // dirLayout->addWidget(new QLabel("Dir:"), 0, 0);
  // dirLayout->addWidget(_outputDir, 0, 2);
  // dirLayout->addWidget(outputDirButton, 0, 4);
  // dirLayout->setColumnStretch(2, 1);
  // verticalLayout->addLayout(dirLayout);

  // // type
  // _typeBox = new QComboBox();
  // _typeBox->addItem("obj");
  // _typeBox->addItem("off");
  // _typeBox->addItem("raw");
  // QHBoxLayout* typeLayout = new QHBoxLayout();
  // typeLayout->addWidget(new QLabel("Type:"), 0, Qt::AlignRight);
  // typeLayout->addWidget(_typeBox, 0, Qt::AlignRight);
  // verticalLayout->addLayout(typeLayout);

  // ok and cancel
  buttonBox = new QDialogButtonBox(this);
  buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
  buttonBox->setOrientation(Qt::Horizontal);
  buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
  verticalLayout->addWidget(buttonBox);

  setWindowTitle("Close Geometry");

  QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
  QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

  QMetaObject::connectSlotsByName(this);

  std::vector<std::string> keys = cvcapp.data<cvcraw_geometry::cvcgeom_t>();
  
  if(keys.empty()) {
    QMessageBox::information(this, tr("Laplace Skeletonization"),
                             tr("No geometry loaded."), QMessageBox::Ok);
  }
  else {
    gridLayout->addWidget(new QLabel("Geometry"), 0, 0);
    // gridLayout->setColumnMinimumWidth(1, 5);
    gridLayout->addWidget(new QLabel("Output filename"), 0, 2);
    gridLayout->setColumnStretch(2, 1);

    BOOST_FOREACH(std::string key, keys) {
      const cvcraw_geometry::cvcgeom_t geom =
          boost::any_cast<cvcraw_geometry::cvcgeom_t>(cvcapp.data()[key]);
      if (geom.points().size() > 0) {
        string ext(".raw");
        switch (GetType(geom)) {
          case kRaw:
            ext = ".raw";
            break;
          case kRawn:
            ext = ".rawn";
            break;
          case kRawc:
            ext = ".rawc";
            break;
          case kRawnc:
            ext = ".rawnc";
            break;
        }
        const int i = _boxes.size();
        _boxes.push_back(new QCheckBox(QString::fromStdString(key)));//, this));
        // _filenames.push_back(new QLineEdit(QString::fromStdString(key+ext)));//, this));
        _filenames.push_back(new QLineEdit(QString::fromStdString(key)));//, this));

        _boxes[i]->setCheckState(Qt::Checked);

        gridLayout->addWidget(_boxes[i], i+1, 0);
        gridLayout->addWidget(_filenames[i], i+1, 2);
      }
    }
    QSize size = gridLayout->minimumSize();
    scrollArea->setMinimumSize(QSize(min(size.width()+10, 400), min(size.height()+10, 300)));
  }

  resize(minimumSizeHint());
}
QTM_USE_NAMESPACE

EventOccurrenceEditPage::EventOccurrenceEditPage(QWidget *parent)
    :QWidget(parent),
    m_manager(0),
    scrollAreaLayout(0),
    m_typeComboBox(0),
    m_subjectEdit(0),
    m_countSpinBox(0),
    m_repeatUntilDate(0)
{
    //create asynch request to save an item
    m_saveItemRequest = new QOrganizerItemSaveRequest(this);
    // Create widgets
    QLabel *subjectLabel = new QLabel("Subject:", this);
    m_subjectEdit = new QLineEdit(this);
    QLabel *startTimeLabel = new QLabel("Start time:", this);
    m_startTimeEdit = new QDateTimeEdit(this);
    m_startTimeEdit->setDisplayFormat(QString("yyyy-MM-dd hh:mm:ss AP"));
    QLabel *endTimeLabel = new QLabel("End time:", this);
    m_endTimeEdit = new QDateTimeEdit(this);
    m_endTimeEdit->setDisplayFormat(QString("yyyy-MM-dd hh:mm:ss AP"));

#if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR))
    // Add push buttons for Maemo as it does not support soft keys
    QHBoxLayout* hbLayout = new QHBoxLayout();
    QPushButton *okButton = new QPushButton("Ok", this);
    connect(okButton,SIGNAL(clicked()),this,SLOT(saveOrNextClicked()));
    hbLayout->addWidget(okButton);
    QPushButton *cancelButton = new QPushButton("Cancel", this);
    connect(cancelButton,SIGNAL(clicked()),this,SLOT(cancelClicked()));
    hbLayout->addWidget(cancelButton);
#endif

    scrollAreaLayout = new QVBoxLayout();
    scrollAreaLayout->addWidget(subjectLabel);
    scrollAreaLayout->addWidget(m_subjectEdit);
    scrollAreaLayout->addWidget(startTimeLabel);
    scrollAreaLayout->addWidget(m_startTimeEdit);
    scrollAreaLayout->addWidget(endTimeLabel);
    scrollAreaLayout->addWidget(m_endTimeEdit);
    scrollAreaLayout->addStretch();

#if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR))
    scrollAreaLayout->addLayout(hbLayout);
#endif

    QScrollArea *scrollArea = new QScrollArea(this);
    scrollArea->setWidgetResizable(true);
    QWidget *formContainer = new QWidget(scrollArea);
    formContainer->setLayout(scrollAreaLayout);
    scrollArea->setWidget(formContainer);

    QVBoxLayout *mainLayout = new QVBoxLayout();
    mainLayout->addWidget(scrollArea);
    setLayout(mainLayout);

    // Add softkeys
    QAction* cancelSoftKey = new QAction("Cancel", this);
    cancelSoftKey->setSoftKeyRole(QAction::NegativeSoftKey);
    addAction(cancelSoftKey);
    connect(cancelSoftKey, SIGNAL(triggered(bool)), this, SLOT(cancelClicked()));

    m_saveOrNextSoftKey = new QAction("Save",this);
    m_saveOrNextSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
    addAction(m_saveOrNextSoftKey);
    connect(m_saveOrNextSoftKey, SIGNAL(triggered(bool)), this, SLOT(saveOrNextClicked()));
    m_countFieldAdded = false;
    m_multipleEntries = false;
    m_listOfEvents.clear();
}