void TestAnalysisTab::testCommentBox() {
    //Add yuc and 2 decoded videos
    QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    qApp->processEvents();
    QTest::qSleep(500);
    loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
    //we skip pressing the "Add video" button and use the UndoStack instead
    GUI::AnalysisBoxContainer* boxCon = mw->findChildren<GUI::AnalysisBoxContainer*>().first();
    QVERIFY2(boxCon != NULL, "Could not find AnalysisBoxContainer");
    UndoRedo::AddVideo* addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
    UndoRedo::UndoStack::getUndoStack().push(addVideo);
    QCoreApplication::processEvents();
    QTest::qSleep(2000);
    QCoreApplication::processEvents();
    addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
    UndoRedo::UndoStack::getUndoStack().push(addVideo);
    QCoreApplication::processEvents();
    QTest::qSleep(2000);
    QCoreApplication::processEvents();
    QPlainTextEdit* lineEditBox1 = mw->findChildren<GUI::AnalysisBox*>().first()->findChildren<QPlainTextEdit*>().first();
    QPlainTextEdit* lineEditBox2 = mw->findChildren<GUI::AnalysisBox*>().at(1)->findChildren<QPlainTextEdit*>().first();

    tabWidget = mw->findChildren<GUI::AnalysisBox*>().first()->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    qApp->processEvents();
    tabWidget = mw->findChildren<GUI::AnalysisBox*>().at(1)->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    qApp->processEvents();
    lineEditBox1->selectAll();
    QApplication::postEvent(lineEditBox1,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier,"test 1"));
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1", "Error writing comment");
    TestMainWindow::triggerAction("Undo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() != "test 1", "Error undoing the writing of a comment");
    TestMainWindow::triggerAction("Redo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1", "Error redoing the writing of a comment");
    lineEditBox2->selectAll();
    QApplication::postEvent(lineEditBox2,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier,"test 2"));
    TestMainWindow::waitForWindow(300);
    QApplication::postEvent(lineEditBox1,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier,"continue writing"));
    TestMainWindow::waitForWindow(300);
    QApplication::postEvent(lineEditBox2,new QKeyEvent(QEvent::KeyPress,Qt::Key_A,Qt::NoModifier," more"));
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1continue writing", "Error writing comment");
    QVERIFY2(lineEditBox2->toPlainText() == "test 2 more", "Error writing comment");
    TestMainWindow::triggerAction("Undo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1continue writing", "Error writing comment");
    QVERIFY2(lineEditBox2->toPlainText() != "test 2 more", "Error undoing writing a comment");
    TestMainWindow::triggerAction("Redo");
    TestMainWindow::waitForWindow(300);
    QVERIFY2(lineEditBox1->toPlainText() == "test 1continue writing", "Error writing comment");
    QVERIFY2(lineEditBox2->toPlainText() == "test 2 more", "Error undoing writing a comment");
}
Exemplo n.º 2
0
void Tabs::setCurrentTab(int index, bool suppressSignals)
{
    QTabWidget *qtabwidget = static_cast<QTabWidget*>(getQWidget());
    bool oldSignalsState = qtabwidget->blockSignals(suppressSignals);
    qtabwidget->setCurrentIndex(index);
    qtabwidget->blockSignals(oldSignalsState);
}
Exemplo n.º 3
0
void tst_QWidget_window::tst_recreateWindow_QTBUG40817()
{
    QTabWidget tab;

    QWidget *w = new QWidget;
    tab.addTab(w, "Tab1");
    QVBoxLayout *vl = new QVBoxLayout(w);
    QLabel *lbl = new QLabel("HELLO1");
    lbl->setObjectName("label1");
    vl->addWidget(lbl);
    w = new QWidget;
    tab.addTab(w, "Tab2");
    vl = new QVBoxLayout(w);
    lbl = new QLabel("HELLO2");
    lbl->setAttribute(Qt::WA_NativeWindow);
    lbl->setObjectName("label2");
    vl->addWidget(lbl);

    tab.show();

    QVERIFY(QTest::qWaitForWindowExposed(&tab));

    QWindow *win = tab.windowHandle();
    win->destroy();
    QWindowPrivate *p = qt_window_private(win);
    p->create(true);
    win->show();

    tab.setCurrentIndex(1);
}
Exemplo n.º 4
0
void RevsView::setTabLogDiffVisible(bool b) {

	QStackedWidget* s = tab()->stackedPanes;
	QTabWidget* t = tab()->tabLogDiff;

	bool isTabPage = (s->currentIndex() == 0);
	int idx = (isTabPage ? t->currentIndex() : s->currentIndex());

	container->setUpdatesEnabled(false);

	if (b && !isTabPage) {

		t->addTab(tab()->textBrowserDesc, "Log");
		t->addTab(tab()->textEditDiff, "Diff");

		t->setCurrentIndex(idx - 1);
		s->setCurrentIndex(0);
	}
	if (!b && isTabPage) {

		s->addWidget(tab()->textBrowserDesc);
		s->addWidget(tab()->textEditDiff);

		// manually remove the two remaining empty pages
		t->removeTab(0); t->removeTab(0);

		s->setCurrentIndex(idx + 1);
	}
	container->setUpdatesEnabled(true);
}
void TestAnalysisTab::testAddVideo() {
	QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
	tabWidget->setCurrentIndex(1);
	qApp->processEvents();
	QTest::qSleep(500);
	loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
	//we skip pressing the "Add video" button and use the UndoStack instead
	GUI::AnalysisBoxContainer* boxCon = mw->findChildren<GUI::AnalysisBoxContainer*>().first();
	QVERIFY2(boxCon != NULL, "Could not find AnalysisBoxContainer");
	UndoRedo::AddVideo* addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
	UndoRedo::UndoStack::getUndoStack().push(addVideo);
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QCoreApplication::processEvents();
	QVERIFY2(mw->getMemento()->getAnalysisTabMemento()->getAnalysisBoxContainerMemento()->getAnalysisBoxList().size()
	         == 1,"Could not add video");
	//test UndoRedo
	TestMainWindow::triggerAction("Undo");
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QVERIFY2(mw->getMemento()->getAnalysisTabMemento()->getAnalysisBoxContainerMemento()->getAnalysisBoxList().size()
	         == 0,"Could not undo the adding of a video");
	TestMainWindow::triggerAction("Redo");
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QVERIFY2(mw->getMemento()->getAnalysisTabMemento()->getAnalysisBoxContainerMemento()->getAnalysisBoxList().size()
	         == 1,"Could not redo the adding of a video");
}
Exemplo n.º 6
0
PreferencesDialog::PreferencesDialog(QWidget* parent)
    : QDialog(parent)
{
    this->setWindowTitle(tr("Preferences"));
    appSettings = AppSettings::getInstance();

    QTabWidget* tabWidget = new QTabWidget(this);

    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget(tabWidget);
    this->setLayout(layout);

    tabWidget->addTab(initializeGeneralTab(), tr("General"));
    tabWidget->addTab(initializeEditorTab(), tr("Editor"));
    tabWidget->addTab(initializeSpellCheckTab(), tr("Spell Check"));
    tabWidget->addTab(initializeHudTab(), tr("HUD"));

    QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
    buttonBox->addButton(QDialogButtonBox::Close);
    layout->addWidget(buttonBox);

    connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));

    tabWidget->setCurrentIndex(0);
}
Exemplo n.º 7
0
/**
 * Called when double-clicking a contact in the contact list.
 * Creates a new conversation with a new id, and a new tab.
 * @brief MainWindow::newPrivateConvo
 */
void MainWindow::newPrivateConvo()
{
    QString pConvo(ui->lstContacts->selectedItems().at(0)->data(Qt::DisplayRole).toString());
    QTabWidget* grp = ui->tabgrpConversations;

    QStringList t = pConvo.split("/", QString::SkipEmptyParts);
    createTab(QString::number(QDateTime::currentMSecsSinceEpoch()), t.at(1), t.at(0));

    //Set selected tab to newly created
    grp->setCurrentIndex(grp->count()-1);
}
/**
 * Activates the page at position \a index of the group with name \a group.
 */
void DlgPreferencesImp::activateGroupPage(const QString& group, int index)
{
    int ct = ui->listBox->count();
    for (int i=0; i<ct; i++) {
        QListWidgetItem* item = ui->listBox->item(i);
        if (item->data(Qt::UserRole).toString() == group) {
            ui->listBox->setCurrentItem(item);
            QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i);
            tabWidget->setCurrentIndex(index);
            break;
        }
    }
}
Exemplo n.º 9
0
void Prefs::activateGroupPage(QString group, int index) {
    int ct = listBox->count();

    for (int i = 0; i < ct; i++) {
        QListWidgetItem* item = listBox->item(i);
        if (item->data(Qt::UserRole).toString() == group) {
            listBox->setCurrentItem(item);
            QTabWidget* tabWidget = (QTabWidget*)tabWidgetStack->widget(i);
            tabWidget->setCurrentIndex(index);
            break;
        }
    }
}
Exemplo n.º 10
0
void UHMM3PhmmerDialogFiller::commonScenario(){
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog != NULL, "dialog not found");

    GTGlobals::sleep(1000);
    QTabWidget* tabWidget = GTWidget::findExactWidget<QTabWidget*>(os, "mainTabWidget", dialog);

    tabWidget->setCurrentIndex(0);
    QLineEdit* queryLineEdit = GTWidget::findExactWidget<QLineEdit*>(os, "queryLineEdit", dialog);
    GTLineEdit::setText(os, queryLineEdit, input);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void TestMainWindow::testSwitchTab() {

	std::unique_ptr<Memento::MainWindowMemento> oldMemo = mw->getMemento();
	QTest::qSleep(500);
	//the tab widget we need is always the first as the search is recursiv
	QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
	tabWidget->setCurrentIndex(1);
	qApp->processEvents();
	QTest::qSleep(500);
	std::unique_ptr<Memento::MainWindowMemento> newMemo = mw ->getMemento();
	QVERIFY(oldMemo->getSelectedTab() != newMemo->getSelectedTab());

}
void TestMainWindow::testCrazyMonkeyClicks() {
    clickButton("Apply to video");
    clickButton("Filter up");
    clickButton("Apply to video");
    clickButton("Filter down");
    clickButton("Save configuration");
    clickButton("Add Edge filter");
    QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
    tabWidget->setCurrentIndex(1);
    clickButton("PSNR");
    clickButton("Bitrate");
    clickButton("Red histogram");
    TestAnalysisTab::loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
    clickButton("PSNR");
    clickButton("Bitrate");
    clickButton("Red histogram");
    tabWidget->setCurrentIndex(0);
    clickButton("Remove filter");
    clickButton("Save configuration");
    clickButton("Add Contrast filter");
    TestFilterTab::loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
    clickButton("Add Vintage filter");
    clickButton("Apply to video");
    triggerAction("Redo");
    triggerAction("Redo");
    triggerAction("Redo");
    clickButton("Add Vintage filter");
    triggerAction("Redo");
    triggerAction("Undo");
    tabWidget->setCurrentIndex(1);
    triggerAction("New");
    clickButton("Add video");





}
void TestAnalysisTab::testGraphs() {
	//Add yuc and decoded video
	QTabWidget* tabWidget = mw->findChildren<QTabWidget*>().first();
	tabWidget->setCurrentIndex(1);
	qApp->processEvents();
	QTest::qSleep(500);
	loadVideo(QFINDTESTDATA("blumeYuv420_planar_176x144.yuv"));
	//we skip pressing the "Add video" button and use the UndoStack instead
	GUI::AnalysisBoxContainer* boxCon = mw->findChildren<GUI::AnalysisBoxContainer*>().first();
	QVERIFY2(boxCon != NULL, "Could not find AnalysisBoxContainer");
	UndoRedo::AddVideo* addVideo = new UndoRedo::AddVideo(boxCon,QFINDTESTDATA("blume.mp4"));
	UndoRedo::UndoStack::getUndoStack().push(addVideo);
	QCoreApplication::processEvents();
	QTest::qSleep(2000);
	QCoreApplication::processEvents();

	TestMainWindow::clickButton("Red histogram");
	QTest::qSleep(1000);
	//raw vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(600,110))==255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(360,250))!=255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(525,260))==255 , "Failed clicking Red histogramm");
	//encoded vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(570,500))==255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(330,600))!=255 , "Failed clicking Red histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(470,600))==255 , "Failed clicking Red histogramm");

	TestMainWindow::clickButton("Green histogram");
	QTest::qSleep(1000);
	//raw vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(600,110))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(360,250))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(525,260))!=255 , "Failed clicking Green histogramm");
	//encoded vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(570,500))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(330,600))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(470,630))!=255 , "Failed clicking Green histogramm");

	TestMainWindow::clickButton("Blue histogram");
	QTest::qSleep(1000);
	//raw vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(600,110))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(340,250))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(525,260))==255 , "Failed clicking Green histogramm");
	//encoded vid
	QVERIFY2(qGray(mw->grab().toImage().pixel(550,500))==255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(345,600))!=255 , "Failed clicking Green histogramm");
	QVERIFY2(qGray(mw->grab().toImage().pixel(470,600))==255 , "Failed clicking Green histogramm");
}
GUI::MainWindow* TestMainWindow::getMainWindow() {
	if(mainWindow) {
        triggerAction("New");
        QTabWidget* tabWidget = mainWindow->findChildren<QTabWidget*>().first();
        tabWidget->setCurrentIndex(0);
		qApp->processEvents();
	} else {
		mainWindow = new GUI::MainWindow();
		originMemento = mainWindow->getMemento();
		mainWindow->show();
		QTest::qWaitForWindowActive(mainWindow);
	}
    waitForWindow(300);
	return mainWindow;
}
Exemplo n.º 15
0
void RevsView::toggleDiffView() {

	QStackedWidget* s = tab()->stackedPanes;
	QTabWidget* t = tab()->tabLogDiff;

	bool isTabPage = (s->currentIndex() == 0);
	int idx = (isTabPage ? t->currentIndex() : s->currentIndex());

	bool old = container->updatesEnabled();
	container->setUpdatesEnabled(false);

	if (isTabPage)
		t->setCurrentIndex(1 - idx);
	else
		s->setCurrentIndex(3 - idx);

	container->setUpdatesEnabled(old);
}
void DlgPreferencesImp::applyChanges()
{
    try {
        for (int i=0; i<ui->tabWidgetStack->count(); i++) {
            QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i);
            for (int j=0; j<tabWidget->count(); j++) {
                QWidget* page = tabWidget->widget(j);
                int index = page->metaObject()->indexOfMethod("checkSettings()");
                try {
                    if (index >= 0) {
                        page->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0);
                    }
                }
                catch (const Base::Exception& e) {
                    ui->listBox->setCurrentRow(i);
                    tabWidget->setCurrentIndex(j);
                    QMessageBox::warning(this, tr("Wrong parameter"), QString::fromAscii(e.what()));
                    throw;
                }
            }
        }
    } catch (const Base::Exception&) {
        this->invalidParameter = true;
        return;
    }

    for (int i=0; i<ui->tabWidgetStack->count(); i++) {
        QTabWidget* tabWidget = (QTabWidget*)ui->tabWidgetStack->widget(i);
        for (int j=0; j<tabWidget->count(); j++) {
            PreferencePage* page = qobject_cast<PreferencePage*>(tabWidget->widget(j));
            if (page)
                page->saveSettings();
        }
    }

    bool saveParameter = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")->
                          GetBool("SaveUserParameter", true);
    if (saveParameter) {
        ParameterManager* parmgr = App::GetApplication().GetParameterSet("User parameter");
        parmgr->SaveDocument(App::Application::Config()["UserParameter"].c_str());
    }
}
Exemplo n.º 17
0
void NotepadForm::jumptab()
{
	if (parent())
	{
		QTabWidget* p = qobject_cast<QTabWidget*>(parent()->parent());
		if (p)
		{
			qint32 max = p->count();
			qint32 cur = p->indexOf(this);

			if (sender()->objectName().startsWith('n')) {
				if (++cur >= max) cur = 0;
			} else {
				if (--cur < 0) cur = (max>0) ? (max-1) : 0;
			}

			p->setCurrentIndex(cur);
		}
	}
}
Exemplo n.º 18
0
void JabberInfo::apply()
{
    if ((m_data == NULL) && (m_client->getState() == Client::Connected)){
        QString errMsg;
        QWidget *errWidget = edtCurrent;
        if (!edtPswd1->text().isEmpty() || !edtPswd2->text().isEmpty()){
            if (edtCurrent->text().isEmpty()){
                errMsg = i18n("Input current password");
            }else{
                if (edtPswd1->text() != edtPswd2->text()){
                    errMsg = i18n("Confirm password does not match");
                    errWidget = edtPswd2;
                }else if (edtCurrent->text() != m_client->getPassword()){
                    errMsg = i18n("Invalid password");
                }
            }
        }
        if (!errMsg.isEmpty()){
            for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
                QTabWidget *tb = qobject_cast<QTabWidget*>(p);
                if (!tb)
                    continue;
                tb->setCurrentIndex(tb->indexOf(this));
                break;
            }
            emit raise(this);
            BalloonMsg::message(errMsg, errWidget);
            return;
        }
        if (!edtPswd1->text().isEmpty())
            m_client->changePassword(edtPswd1->text());
        // clear Textboxes
        edtCurrent->clear();
        edtPswd1->clear();
        edtPswd2->clear();
    }
}
		void setupUi(QDialog *dialog)
		{
			vbl = new QVBoxLayout(dialog);

			name = new QLabel(dialog);
			name->setTextFormat(Qt::RichText);
			name->setWordWrap(true);
			name->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
			vbl->addWidget(name);

			status = new QLabel(dialog);
			status->setWordWrap(true);
			status->setTextFormat(Qt::RichText);
			status->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
			vbl->addWidget(status);

			profileTabs = new QTabWidget(dialog);
			profileTab = new QTextEdit();
			profileTab->setReadOnly(true);
			profileTabs->addTab(profileTab, QString("Profile"));
			kinkTab = new QTextEdit();
			kinkTab->setReadOnly(true);
			profileTabs->addTab(kinkTab, QString("Kinks"));
			profileTabs->setCurrentIndex(0);
			vbl->addWidget(profileTabs);

			buttons = new QDialogButtonBox(Qt::Horizontal, dialog);
			closeButton = new QPushButton(QIcon(":/images/cross.png"), QString("Close"));
			buttons->addButton(closeButton, QDialogButtonBox::RejectRole);
			vbl->addWidget(buttons);

			dialog->setLayout(vbl);
			dialog->setWindowTitle(QString("Character Info"));

			QObject::connect(buttons, SIGNAL(rejected()), dialog, SLOT(reject()));
			QMetaObject::connectSlotsByName(dialog);
		}
Exemplo n.º 20
0
    OLD_MAIN(QWidget* pParent = nullptr)
        : QMainWindow(pParent)
    {
        Q_INIT_RESOURCE(Resources);

        // Settings persistence
        ReadSettings();

        // Appearance LUT
        PlayerApperances appearances;

        // Build player table model from file
        PlayerTableModel* playerTableModel = new PlayerTableModel(this);
        playerTableModel->LoadHittingProjections(appearances);
        playerTableModel->LoadPitchingProjections(appearances);
        playerTableModel->CalculateHittingScores();
        playerTableModel->CalculatePitchingScores();
        playerTableModel->InitializeTargetValues();

        // Draft delegate
        DraftDelegate* draftDelegate = new DraftDelegate(playerTableModel);
        LinkDelegate* linkDelegate = new LinkDelegate(this);
        TagDelegate* tagDelegate = new TagDelegate(this);

        // Hitter sort-model
        PlayerSortFilterProxyModel* hitterSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Hitter);
        hitterSortFilterProxyModel->setSourceModel(playerTableModel);
        hitterSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);

        // Hitter table view
        QTableView* hitterTableView = MakeTableView(hitterSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
        hitterTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);

        // Context menu
        QMenu* contextMenu = new QMenu();
        contextMenu->addAction("&Remove Player");

        // Apply to hitter table view
        hitterTableView->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(hitterTableView, &QWidget::customContextMenuRequested, [=](const QPoint& pos) {
            QPoint globalPos = hitterTableView->mapToGlobal(pos);
            QAction* selectedItem = contextMenu->exec(globalPos);
            if (selectedItem) {
                auto proxyIndex = hitterTableView->indexAt(pos);
                auto srcIndex = hitterSortFilterProxyModel->mapToSource(proxyIndex);
                playerTableModel->RemovePlayer(srcIndex.row());
            }
        });

        // Pitcher sort-model
        PlayerSortFilterProxyModel* pitcherSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Pitcher);
        pitcherSortFilterProxyModel->setSourceModel(playerTableModel);
        pitcherSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);
        
        // Pitcher table view
        QTableView* pitcherTableView = MakeTableView(pitcherSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
        pitcherTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);

        // Top/Bottom splitter
        QSplitter* topBottomSplitter = new QSplitter(Qt::Vertical);
        topBottomSplitter->setContentsMargins(5, 5, 5, 5);

        // Hitter/Pitcher tab View
        enum PlayerTableTabs { Hitters, Pitchers, Unknown };
        QTabWidget* hitterPitcherTabs = new QTabWidget(this);
        hitterPitcherTabs->insertTab(PlayerTableTabs::Hitters, hitterTableView, "Hitters");
        hitterPitcherTabs->insertTab(PlayerTableTabs::Pitchers, pitcherTableView, "Pitchers");
        topBottomSplitter->addWidget(hitterPitcherTabs);

        // Tab lookup helper
        auto CaterogyToTab = [](uint32_t catergory) 
        {
            switch (catergory)
            {
            case Player::Hitter:
                return PlayerTableTabs::Hitters;
            case Player::Pitcher:
                return PlayerTableTabs::Pitchers;
            default:
                return PlayerTableTabs::Unknown;
            }
        };

        // Drafted filter action
        QAction* filterDrafted = new QAction(this);
        connect(filterDrafted, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
        connect(filterDrafted, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
        filterDrafted->setText(tr("Drafted"));
        filterDrafted->setToolTip("Toggle Drafted Players");
        filterDrafted->setCheckable(true);
        filterDrafted->toggle();

        QAction* filterReplacement = new QAction(this);
        connect(filterReplacement, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement);
        connect(filterReplacement, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement);
        filterReplacement->setText(tr("($1)"));
        filterReplacement->setToolTip("Toggle replacements players with value under $1");
        filterReplacement->setCheckable(true);
        filterReplacement->toggle();

        // NL filter action
        QAction* filterNL = new QAction(this);
        connect(filterNL, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterNL);
        connect(filterNL, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterNL);
        filterNL->setText(tr("NL"));
        filterNL->setToolTip("Toggle National Leauge");
        filterNL->setCheckable(true);
        filterNL->toggle();

        // AL filter action
        QAction* filterAL = new QAction(this);
        connect(filterAL, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterAL);
        connect(filterAL, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterAL);
        filterAL->setText(tr("AL"));
        filterAL->setToolTip("Toggle American Leauge");
        filterAL->setCheckable(true);
        filterAL->toggle();

        // FA filter action
        QAction* filterFA = new QAction(this);
        connect(filterFA, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterFA);
        connect(filterFA, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterFA);
        filterFA->setText(tr("FA"));
        filterFA->setToolTip("Toggle Free Agents");
        filterFA->setCheckable(true);
        filterAL->toggle();
        filterAL->toggle();

        // General filter group
        QActionGroup* generalFilters = new QActionGroup(this);
        generalFilters->addAction(filterAL);
        generalFilters->addAction(filterNL);
        generalFilters->addAction(filterFA);
        generalFilters->setExclusive(false);

        // Starter filter action
        QAction* filterStarter = new QAction(this);
        connect(filterStarter, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterSP);
        filterStarter->setText(tr("SP"));
        filterStarter->setToolTip("Toggle Starting Pitchers");
        filterStarter->setCheckable(true);
        filterStarter->toggle();

        // Relief filter action
        QAction* filterRelief = new QAction(this);
        connect(filterRelief, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterRP);
        filterRelief->setText(tr("RP"));
        filterRelief->setToolTip("Toggle Relief Pitchers");
        filterRelief->setCheckable(true);
        filterRelief->toggle();

        // Pitching filter group
        QActionGroup* pitchingFilters = new QActionGroup(this);
        pitchingFilters->addAction(filterStarter);
        pitchingFilters->addAction(filterRelief);
        pitchingFilters->setExclusive(false);

        // Hitting filter group
        QActionGroup* hittingFilters = new QActionGroup(this);
        hittingFilters->setExclusive(false);

        // Filter helper
        auto MakeHitterFilter = [=](QString text, QString toolTip, const auto& onFilterFn) -> QAction* 
        {
            QAction* action = new QAction(this);
            connect(action, &QAction::toggled, hitterSortFilterProxyModel, onFilterFn);
            action->setText(text);
            action->setToolTip(toolTip);
            action->setCheckable(true);
            action->toggle();
            hittingFilters->addAction(action);

            return action;
        };

        // Hitter filters
        QAction* filterC  = MakeHitterFilter("C",  "Filter Catchers",           &PlayerSortFilterProxyModel::OnFilterC);
        QAction* filter1B = MakeHitterFilter("1B", "Filter 1B",                 &PlayerSortFilterProxyModel::OnFilter1B);
        QAction* filter2B = MakeHitterFilter("2B", "Filter 2B",                 &PlayerSortFilterProxyModel::OnFilter2B);
        QAction* filterSS = MakeHitterFilter("SS", "Filter SS",                 &PlayerSortFilterProxyModel::OnFilterSS);
        QAction* filter3B = MakeHitterFilter("3B", "Filter 3B",                 &PlayerSortFilterProxyModel::OnFilter3B);
        QAction* filterOF = MakeHitterFilter("OF", "Filter Outfielders",        &PlayerSortFilterProxyModel::OnFilterOF);
        QAction* filterCI = MakeHitterFilter("CI", "Filter Corner Infielders",  &PlayerSortFilterProxyModel::OnFilterCI);
        QAction* filterMI = MakeHitterFilter("MI", "Filter Middle Infielders",  &PlayerSortFilterProxyModel::OnFilterMI);
        QAction* filterDH = MakeHitterFilter("DH", "Filter Designated Hitters", &PlayerSortFilterProxyModel::OnFilterDH);
        QAction* filterU  = MakeHitterFilter("U",  "Filter Utility",            &PlayerSortFilterProxyModel::OnFilterU);

        // Menu spacer
        QWidget* spacer = new QWidget(this);
        spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

        // Completion Widget
        QCompleter* completer = new QCompleter(this);
        completer->setModel(playerTableModel);
        completer->setCompletionColumn(PlayerTableModel::COLUMN_NAME);
        completer->setFilterMode(Qt::MatchContains);
        completer->setCaseSensitivity(Qt::CaseInsensitive);

        // Select
        auto HighlightPlayerInTable = [=](const QModelIndex& srcIdx)
        {
            // Lookup catergory
            auto catergoryIdx = srcIdx.model()->index(srcIdx.row(), PlayerTableModel::COLUMN_CATERGORY);
            auto catergory = srcIdx.model()->data(catergoryIdx).toUInt();

            // Change to tab
            hitterPitcherTabs->setCurrentIndex(CaterogyToTab(catergory));

            // Select row
            if (catergory == Player::Catergory::Hitter) {
                auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(hitterTableView->model());
                auto proxyIdx = proxyModel->mapFromSource(srcIdx);
                hitterTableView->selectRow(proxyIdx.row());
                hitterTableView->setFocus();
            } else if (catergory == Player::Catergory::Pitcher) {
                auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(pitcherTableView->model());
                auto proxyIdx = proxyModel->mapFromSource(srcIdx);
                pitcherTableView->selectRow(proxyIdx.row());
                pitcherTableView->setFocus();
            }
        };

        // Select the target 
        connect(completer, static_cast<void (QCompleter::*)(const QModelIndex&)>(&QCompleter::activated), [=](const QModelIndex& index) {

            // Get player index
            QAbstractProxyModel* proxyModel = dynamic_cast<QAbstractProxyModel*>(completer->completionModel());
            auto srcIdx = proxyModel->mapToSource(index);
            
            // Highlight this player
            HighlightPlayerInTable(srcIdx);
        });


        // Search widget
        QLineEdit* playerSearch = new QLineEdit(this);
        playerSearch->setCompleter(completer);

        // Main toolbar
        QToolBar* toolbar = new QToolBar("Toolbar");
        toolbar->addWidget(new QLabel(" Status: ", this));
        toolbar->addActions(QList<QAction*>{filterDrafted, filterReplacement});
        toolbar->addSeparator();
        toolbar->addWidget(new QLabel(" Leagues: ", this));
        toolbar->addActions(QList<QAction*>{filterAL, filterNL, filterFA});
        toolbar->addSeparator();
        toolbar->addWidget(new QLabel(" Positions: ", this));
        toolbar->addActions(QList<QAction*>{filterStarter, filterRelief});
        toolbar->addActions(QList<QAction*>{filterC, filter1B, filter2B, filterSS, filter3B, filterOF, filterCI, filterMI, filterDH, filterU});
        toolbar->addWidget(spacer);
        toolbar->addWidget(new QLabel("Player Search: ", this));
        toolbar->addWidget(playerSearch);
        toolbar->setFloatable(false);
        toolbar->setMovable(false);
        QMainWindow::addToolBar(toolbar);

        // Helper to adjust filters
        auto ToggleFilterGroups = [=](int index)
        {
            switch (index)
            {
            case uint32_t(PlayerTableTabs::Hitters):
                pitchingFilters->setVisible(false);
                hittingFilters->setVisible(true);
                break;
            case uint32_t(PlayerTableTabs::Pitchers):
                pitchingFilters->setVisible(true);
                hittingFilters->setVisible(false);
                break;
            default:
                break;
            }
        };

        // Set default filter group
        ToggleFilterGroups(hitterPitcherTabs->currentIndex());

        //---------------------------------------------------------------------
        // Bottom Section
        //---------------------------------------------------------------------

        // Owner widget
        QHBoxLayout* ownersLayout = new QHBoxLayout(this);
        ownersLayout->setSizeConstraint(QLayout::SetNoConstraint);

        // Owner models
        std::vector<OwnerSortFilterProxyModel*> vecOwnerSortFilterProxyModels;

        // Owner labels
        QList<QLabel*>* pVecOwnerLabels;
        pVecOwnerLabels = new QList<QLabel*>();
        pVecOwnerLabels->append(new QLabel("--"));
        for (auto i = 1u; i <= DraftSettings::Get().OwnerCount; i++) {
            pVecOwnerLabels->append(new QLabel(DraftSettings::Get().OwnerNames[i]));
        }

        // Update label helper
        auto UpdateOwnerLabels = [=]() {
            for (auto i = 1u; i <= DraftSettings::Get().OwnerCount; i++) {
                pVecOwnerLabels->at(i)->setText(DraftSettings::Get().OwnerNames[i]);
            }
        };

        // Initialize
        UpdateOwnerLabels();

        // Loop owners
        for (uint32_t ownerId = 1; ownerId <= DraftSettings::Get().OwnerCount; ownerId++) {

            // V-Layout per owner
            QVBoxLayout* perOwnerLayout = new QVBoxLayout(this);
            ownersLayout->addLayout(perOwnerLayout);
            perOwnerLayout->setSizeConstraint(QLayout::SetNoConstraint);

            // Proxy model for this owner
            OwnerSortFilterProxyModel* ownerSortFilterProxyModel = new OwnerSortFilterProxyModel(ownerId, playerTableModel, this);
            vecOwnerSortFilterProxyModels.push_back(ownerSortFilterProxyModel);

            // Owner name label
            pVecOwnerLabels->at(ownerId)->setAlignment(Qt::AlignCenter);
            perOwnerLayout->addWidget(pVecOwnerLabels->at(ownerId));

            // Per-owner roster table view
            const uint32_t tableWidth = 225;
            QTableView* ownerRosterTableView = MakeTableView(ownerSortFilterProxyModel, true, 0);
            ownerRosterTableView->setMinimumSize(tableWidth, 65);
            ownerRosterTableView->setMaximumSize(tableWidth, 4096);
            ownerRosterTableView->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
            perOwnerLayout->addWidget(ownerRosterTableView);

            // XXX: This should be a form layout...
            QGridLayout* ownerSummaryGridLayout = new QGridLayout(this);
            ownerSummaryGridLayout->setSpacing(0);
            ownerSummaryGridLayout->addWidget(MakeLabel("Budget: "),     0, 0);
            ownerSummaryGridLayout->addWidget(MakeLabel("# Hitters: "),  1, 0);
            ownerSummaryGridLayout->addWidget(MakeLabel("# Pitchers: "), 2, 0);
            ownerSummaryGridLayout->addWidget(MakeLabel("Max Bid: "),    3, 0);

            QLabel* budgetLabel = MakeLabel();
            QLabel* numHittersLabel = MakeLabel();
            QLabel* numPitchersLabel = MakeLabel();
            QLabel* maxBidLabel = MakeLabel();

            // Helper
            auto UpdateLabels = [=]()
            {
                budgetLabel->setText(QString("$%1").arg(ownerSortFilterProxyModel->GetRemainingBudget()));
                numHittersLabel->setText(QString("%1 / %2").arg(ownerSortFilterProxyModel->Count(Player::Hitter)).arg(DraftSettings::Get().HitterCount));
                numPitchersLabel->setText(QString("%1 / %2").arg(ownerSortFilterProxyModel->Count(Player::Pitcher)).arg(DraftSettings::Get().PitcherCount));
                maxBidLabel->setText(QString("$%1").arg(ownerSortFilterProxyModel->GetMaxBid()));
            };

            // Update labels when a draft event happens
            connect(playerTableModel, &PlayerTableModel::DraftedEnd, [=]() {
                UpdateLabels();
            });

            UpdateLabels();

            ownerSummaryGridLayout->addWidget(budgetLabel,      0, 1);
            ownerSummaryGridLayout->addWidget(numHittersLabel,  1, 1);
            ownerSummaryGridLayout->addWidget(numPitchersLabel, 2, 1);
            ownerSummaryGridLayout->addWidget(maxBidLabel,      3, 1);

            QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Preferred);

            ownerSummaryGridLayout->addItem(spacer, 0, 2);
            ownerSummaryGridLayout->addItem(spacer, 1, 2);
            ownerSummaryGridLayout->addItem(spacer, 2, 2);
            ownerSummaryGridLayout->addItem(spacer, 3, 2);
            perOwnerLayout->addLayout(ownerSummaryGridLayout);

            perOwnerLayout->addSpacerItem(spacer);
        }

        // Owner widget
        QWidget* scrollAreaWidgetContents = new QWidget(this);
        scrollAreaWidgetContents->setLayout(ownersLayout);
        scrollAreaWidgetContents->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

        // Owner scroll area
        QScrollArea* ownerScrollArea = new QScrollArea(this);
        ownerScrollArea->setWidget(scrollAreaWidgetContents);
        ownerScrollArea->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
        ownerScrollArea->setBackgroundRole(QPalette::Light);
        ownerScrollArea->setFrameShape(QFrame::NoFrame);
        ownerScrollArea->setWidgetResizable(true);

        // Target value widget
        QWidget* targetValueWidget = new QWidget(this);
        QFormLayout* targetValueLayout = new QFormLayout(this);
        targetValueWidget->setLayout(targetValueLayout);
        auto values = {
            PlayerTableModel::COLUMN_AVG,
            PlayerTableModel::COLUMN_HR,
            PlayerTableModel::COLUMN_R,
            PlayerTableModel::COLUMN_RBI,
            PlayerTableModel::COLUMN_SB,
            PlayerTableModel::COLUMN_SO,
            PlayerTableModel::COLUMN_ERA,
            PlayerTableModel::COLUMN_WHIP,
            PlayerTableModel::COLUMN_W,
            PlayerTableModel::COLUMN_SV,
        };
        for (auto value : values) {
            auto name = playerTableModel->headerData(value, Qt::Horizontal, Qt::DisplayRole).toString();
            auto target = QString::number(playerTableModel->GetTargetValue(value), 'f', 3);
            targetValueLayout->addRow(name, new QLabel(target));
        }

        // Player scatter plot
        PlayerScatterPlotChart* chartView = new PlayerScatterPlotChart(playerTableModel, hitterSortFilterProxyModel, this);
        connect(hitterSortFilterProxyModel,  &QSortFilterProxyModel::layoutChanged, chartView, &PlayerScatterPlotChart::Update);
        connect(pitcherSortFilterProxyModel, &QSortFilterProxyModel::layoutChanged, chartView, &PlayerScatterPlotChart::Update);
        connect(playerTableModel, &QAbstractItemModel::dataChanged, chartView, &PlayerScatterPlotChart::Update);

        // Summary view
        SummaryWidget* summary = new SummaryWidget(playerTableModel, vecOwnerSortFilterProxyModels, this);

        // Bottom tabs
        enum BottomSectionTabs { Rosters, Summary, Targets, ChartView, Log };
        QTabWidget* bottomTabs = new QTabWidget(this);
        topBottomSplitter->addWidget(bottomTabs);
        bottomTabs->insertTab(BottomSectionTabs::Rosters, ownerScrollArea, "Rosters");
        bottomTabs->insertTab(BottomSectionTabs::Summary, summary, "Summary");
        bottomTabs->insertTab(BottomSectionTabs::Targets, targetValueWidget, "Targets");
        bottomTabs->insertTab(BottomSectionTabs::ChartView, chartView, "Scatter Chart");
        bottomTabs->insertTab(BottomSectionTabs::Log, GlobalLogger::Get(), "Log");

        // Make top section 3x the size of the bottom
        topBottomSplitter->setStretchFactor(0, 3);
        topBottomSplitter->setStretchFactor(1, 1);

        //----------------------------------------------------------------------
        // Connections
        //----------------------------------------------------------------------

        // Connect tab filters
        connect(hitterPitcherTabs, &QTabWidget::currentChanged, this, [=](int index) {
            
            // Update filters
            ToggleFilterGroups(index);

            // Update chart view
            switch (index)
            {
            case PlayerTableTabs::Hitters:
                chartView->SetProxyModel(hitterSortFilterProxyModel);
                break;
            case PlayerTableTabs::Pitchers:
                chartView->SetProxyModel(pitcherSortFilterProxyModel);
                break;
            default:
                break;
            }
        });

        // Connect chart click
        connect(chartView, &PlayerScatterPlotChart::PlayerClicked, this, [=](const QModelIndex& index) {
            HighlightPlayerInTable(index);
        });
        
        // Connect summary model
        connect(playerTableModel, &PlayerTableModel::DraftedEnd, summary, &SummaryWidget::OnDraftedEnd);

        //----------------------------------------------------------------------
        // Main
        //----------------------------------------------------------------------

        // Set as main window
        QMainWindow::setCentralWidget(topBottomSplitter);

        // Create main menu bar
        QMenuBar* mainMenuBar = new QMenuBar();
        QMainWindow::setMenuBar(mainMenuBar);
        
        // Main Menu > File menu
        QMenu* fileMenu = mainMenuBar->addMenu("&File");

        // File dialog helper
        auto GetFileDialog = [&](QFileDialog::AcceptMode mode) -> QFileDialog*
        {
            QFileDialog* dialog = new QFileDialog(this);
            dialog->setWindowModality(Qt::WindowModal);
            dialog->setAcceptMode(mode);
            dialog->setNameFilter("CSV files (*.csv)");
            return dialog;
        };

        // Ask for the save location 
        auto SetSaveAsFile = [=]()
        {
            QStringList files;
            auto dialog = GetFileDialog(QFileDialog::AcceptSave);
            if (dialog->exec()) {
                files = dialog->selectedFiles();
            } else {
                return false;
            }
            m_currentFile = files.at(0);
            return true;
        };

        // Update title bar
        auto UpdateApplicationName = [this]()
        {
            auto name = QString("fbb -- %1").arg(QFileInfo(m_currentFile).fileName());
            QCoreApplication::setApplicationName(name);
            setWindowTitle(name);
        };

        // Main Menu > File menu > Save action
        QAction* saveResultsAction = new QAction("&Save Results", this);
        connect(saveResultsAction, &QAction::triggered, [=](bool checked) {
            if (m_currentFile.isEmpty()) {
                SetSaveAsFile();
            }
            GlobalLogger::AppendMessage(QString("Saving file: %1...").arg(m_currentFile));
            UpdateApplicationName();
            return playerTableModel->SaveDraftStatus(m_currentFile);
        });
        fileMenu->addAction(saveResultsAction);

        // Main Menu > File menu > Save As action
        QAction* saveResultsAsAction = new QAction("Save Results &As...", this);
        connect(saveResultsAsAction, &QAction::triggered, [=](bool checked) {
            SetSaveAsFile();
            GlobalLogger::AppendMessage(QString("Saving file: %1...").arg(m_currentFile));
            UpdateApplicationName();
            return playerTableModel->SaveDraftStatus(m_currentFile);
        });
        fileMenu->addAction(saveResultsAsAction);
        
        // Main Menu > File menu > Load action
        QAction* loadResultsAction = new QAction("&Load Results...", this);
        connect(loadResultsAction, &QAction::triggered, [=](bool checked) {
            auto dialog = GetFileDialog(QFileDialog::AcceptOpen);
            QStringList files;
            if (dialog->exec()) {
                files = dialog->selectedFiles();
            } else {
                return false;
            }
            m_currentFile = files.at(0);
            GlobalLogger::AppendMessage(QString("Loading file: %1...").arg(m_currentFile));
            UpdateApplicationName();
            return playerTableModel->LoadDraftStatus(m_currentFile);
        });
        fileMenu->addAction(loadResultsAction);

        // Main Menu > File menu
        QMenu* settingsMenu = mainMenuBar->addMenu("&Settings");

        // Main Menu > Settings menu > Options action
        QAction* settingsAction = new QAction("&Settings...", this);
        connect(settingsAction, &QAction::triggered, [=](bool checked) {
            DraftSettingsDialog draftSettingsDialog;
            if (draftSettingsDialog.exec()) {
                UpdateOwnerLabels();
            }
        });
        settingsMenu->addAction(settingsAction);

        // Main Menu > Settings menu > Options action
        QAction* demoDataAction = new QAction("&DemoData...", this);
        connect(demoDataAction, &QAction::triggered, [=](bool checked) {
            playerTableModel->DraftRandom();
        });
        settingsMenu->addAction(demoDataAction);

        // show me
        QMainWindow::show();
    }
Exemplo n.º 21
0
// Update associated QWidget / QObject based on treeGuiWidget_ data
void QtWidgetObject::updateQt()
{
	// Check treeGuiWidget_ pointer first
	if (treeGuiWidget_ == NULL)
	{
		printf("Critical Error: treeGuiWidget_ pointer has not been set in QtWidgetObject.\n");
		return;
	}

	// Do generic properties here
	if (qWidget_ != NULL)
	{
		qWidget_->setEnabled(treeGuiWidget_->enabled());
		qWidget_->setVisible(treeGuiWidget_->visible());
		// And corresponding label
		if (labelWidget_ != NULL)
		{
			labelWidget_->setEnabled(treeGuiWidget_->enabled());
			labelWidget_->setVisible(treeGuiWidget_->visible());
		}
	}

	// Now, check widget type to see what we do
	if (treeGuiWidget_->type() == TreeGuiWidget::ButtonWidget)
	{
		QPushButton *button = static_cast<QPushButton*>(qWidget_);
		if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QPushButton.\n");
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget)
	{
		QCheckBox *check = static_cast<QCheckBox*>(qWidget_);
		if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n");
		else
		{
			check->setChecked(treeGuiWidget_->valueI() == 1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget)
	{
		QComboBox* combo = static_cast<QComboBox*>(qWidget_);
		if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n");
		else
		{
			// Has items list been modified since last update
			if (treeGuiWidget_->propertyChanged(TreeGuiWidgetEvent::ItemsProperty))
			{
				combo->clear();
				for (int n=0; n<treeGuiWidget_->comboItems().count(); ++n) combo->addItem(treeGuiWidget_->comboItems().at(n));
				treeGuiWidget_->resetChanged(TreeGuiWidgetEvent::ItemsProperty);
			}
			// Set current index
			combo->setCurrentIndex(treeGuiWidget_->valueI()-1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget)
	{
		QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_);
		if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n");
		else
		{
			spin->setRange(treeGuiWidget_->minimumD(), treeGuiWidget_->maximumD());
			spin->setValue(treeGuiWidget_->valueD());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget)
	{
		QLineEdit *edit = static_cast<QLineEdit*>(qWidget_);
		if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n");
		else
		{
			edit->setText(treeGuiWidget_->text());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget)
	{
		QSpinBox *spin = static_cast<QSpinBox*>(qWidget_);
		if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n");
		else
		{
			spin->setRange(treeGuiWidget_->minimumI(), treeGuiWidget_->maximumI());
			spin->setValue(treeGuiWidget_->valueI());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget)
	{
		QLabel *label = static_cast<QLabel*>(qWidget_);
		if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n");
		else
		{
			label->setText(treeGuiWidget_->text());
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget)
	{
		QRadioButton *button = static_cast<QRadioButton*>(qWidget_);
		if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n");
		else
		{
			button->setChecked(treeGuiWidget_->valueI() == 1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget)
	{
		QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_);
		if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n");
		else
		{
			QAbstractButton *button = butgroup->button(treeGuiWidget_->valueI());
			if (!button) printf("Critical Error: Couldn't find button with id %i in button group.\n", treeGuiWidget_->valueI());
			else button->setChecked(true);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget)
	{
		QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_);
		if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n");
		else
		{
			tabs->setCurrentIndex(treeGuiWidget_->valueI()-1);
		}
	}
	else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget)
	{
		QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_);
		if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n");
		else
		{
			stack->setCurrentIndex(treeGuiWidget_->valueI()-1);
		}
	}
}
Exemplo n.º 22
0
KawaiiGL::KawaiiGL(QWidget *parent)
    : QMainWindow(parent), m_kView(NULL), m_edDlg(NULL), m_doc(NULL)
{
    ui.setupUi(this);

    m_sett.loadFromReg();
    connect(&m_sett, SIGNAL(changed()), &m_sett, SLOT(storeToReg()));

    setWindowTitle("KawaiiGL");
    show(); // needed becase we're creating display lists in the c'tor.

    QDir::setCurrent(EXAMPLES_DIR); // we're reading the config and textures from there

    m_progMenu = new QMenu(this);
    m_modelsMenu = new QMenu(this);

    m_doc = new Document(this); // adds to the menus

    m_progMenu->addSeparator();
    QAction *loadFromFileAct = m_progMenu->addAction("From file...");
    connect(loadFromFileAct, SIGNAL(triggered(bool)), m_doc, SLOT(loadProgramFile()));

    m_kView = new T2GLWidget(this, m_doc);
    setCentralWidget(m_kView);

    m_edDlg = new KwEdit(this, m_sett.disp, m_doc, m_kView); // need the view for tracking vec2s
    m_edDlg->show();
    m_edDlg->move(pos() + QPoint(width() - 20, 30));

    m_control = new MyDialog(this);
    QBoxLayout *control_l = new QVBoxLayout();
    m_control->setLayout(control_l);
    control_l->setMargin(0);
    control_l->setSpacing(0);
    QTabWidget *tabs = new QTabWidget();
    control_l->addWidget(tabs);

    m_contDlg = new ControlPanel(&m_sett.disp, this, m_doc, m_kView);
    tabs->addTab(m_contDlg, "Config");
    m_browse = new ProjBrowser(this, m_doc);
    tabs->addTab(m_browse, "Browser");
    tabs->setCurrentWidget(m_browse);

    //tabs->setCurrentIndex(m_sett.gui.configWindowTab);
    tabs->setCurrentIndex(0);

    m_control->show();
    m_control->move(pos() + QPoint(-30, 20));
    m_control->resize(100, 100); // make it as small as possible

    m_doc->model()->m_errAct = new ErrorHighlight(m_edDlg);

    connect(m_kView, SIGNAL(message(const QString&)), this, SLOT(message(const QString&)));

    connect(m_edDlg, SIGNAL(changedModel(DocSrc*)), m_doc, SLOT(calc(DocSrc*)));
    connect(m_edDlg, SIGNAL(updateShaders()), m_doc, SLOT(compileShaders()));

//	connect(m_kView, SIGNAL(decompProgChanged(const QString&)), m_edDlg, SLOT(curChanged(const QString&)));

    connect(m_doc, SIGNAL(loaded()), m_kView, SLOT(newModelLoaded()));
    //connect(m_doc, SIGNAL(loaded()), m_edDlg, SLOT(doVarsUpdate())); // parsed new text. vars defs may be wrong
    connect(m_doc, SIGNAL(modelChanged()), m_kView, SLOT(updateGL()));
    connect(m_doc, SIGNAL(progChanged()), m_kView, SLOT(redoFrameBuffers()));
    connect(m_kView, SIGNAL(changedFBOs()), m_contDlg, SLOT(updateTexEdits()));
    connect(m_kView, SIGNAL(makeGradientTex(int, const QString&)), m_contDlg, SLOT(externalGradient(int, const QString&)));

    connect(m_doc, SIGNAL(progParamChanged()), m_kView, SLOT(updateGL()));
    connect(m_doc, SIGNAL(addModelLine(const QString&)), m_edDlg, SLOT(addModelLine(const QString&)));

    connect(m_contDlg, SIGNAL(changedRend()), m_doc, SLOT(calcNoParse())); // passes update
    connect(m_contDlg, SIGNAL(changedFont()), m_kView, SLOT(updateCoordFont()));
    connect(m_contDlg, SIGNAL(doUpdate()), m_kView, SLOT(updateGL())); // passes update

    connect(m_contDlg, SIGNAL(resetView()), m_kView, SLOT(resetState()));
    connect(m_contDlg, SIGNAL(resetLight()), m_kView, SLOT(resetLight()));
    connect(m_contDlg, SIGNAL(changedTexFile(int)), m_kView, SLOT(setTexture(int)));
//	connect(m_contDlg, SIGNAL(reassertTex(int)), m_kView, SLOT(rebindTexture(int)));
    connect(m_contDlg, SIGNAL(saveMesh()), m_doc, SLOT(calcSave()));

    connect(m_browse, SIGNAL(openDocText(DocElement*)), m_edDlg, SLOT(addPage(DocElement*)) );
    connect(m_browse, SIGNAL(openPassConf(DocElement*)), m_edDlg, SLOT(addPage(DocElement*)) );
    connect(m_browse, SIGNAL(commitGuiData()), m_edDlg, SLOT(commitAll()));

    connect(m_doc, SIGNAL(goingToClearProg()), m_edDlg, SLOT(clearingProg()));
    connect(m_doc, SIGNAL(didReadProg(ProgKeep*)), m_edDlg, SLOT(readProg(ProgKeep*)) );
    connect(m_doc, SIGNAL(didReadProg(ProgKeep*)), m_browse, SLOT(readProg(ProgKeep*)) );
    connect(m_doc, SIGNAL(didReadModel(DocSrc*)), m_browse, SLOT(readModel()) );
    connect(m_doc, SIGNAL(didReadModel(DocSrc*)), m_edDlg, SLOT(readModel(DocSrc*)));

    connect(&m_sett.disp.bVtxNormals, SIGNAL(changed()), m_doc, SLOT(calcNoParse())); // TBD - this is bad.

    connect(m_contDlg->ui.clipSlider, SIGNAL(valueChanged(int)), m_kView, SLOT(setClipValue(int)));

    m_kView->setContextMenuPolicy(Qt::ActionsContextMenu);

    QPushButton *viewBot = new QPushButton("View");
    viewBot->setMaximumSize(60, 19);
    statusBar()->addPermanentWidget(viewBot);
    QMenu *view = new QMenu("View");
    viewBot->setMenu(view);

    QPushButton *fpsBot = new QPushButton(QIcon(":/images/arrow-circle.png"), QString());
    fpsBot->setMaximumSize(20, 19);
    statusBar()->addPermanentWidget(fpsBot);
    (new CheckBoxIn(&m_sett.disp.fullFps, fpsBot))->reload();

    QCheckBox *vSyncBox = new QCheckBox("vSync");
    vSyncBox->setMaximumHeight(19);
    statusBar()->addPermanentWidget(vSyncBox);
    (new CheckBoxIn(&m_sett.disp.vSync, vSyncBox))->reload();

    QAction *confVis = new QAction("Display", view);
    view->addAction(confVis);
    m_control->connectAction(confVis);
    QAction *editVis = new QAction("Edit", view);
    view->addAction(editVis);
    m_edDlg->connectAction(editVis);

    m_kView->connectedInit();

    processCmdArgs();
}
Exemplo n.º 23
0
static void* ui_companion_qt_init(void)
{
   ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
   MainWindow *mainwindow = NULL;
   QHBoxLayout *browserButtonsHBoxLayout = NULL;
   QVBoxLayout *layout = NULL;
   QVBoxLayout *launchWithWidgetLayout = NULL;
   QHBoxLayout *coreComboBoxLayout = NULL;
   QMenuBar *menu = NULL;
   QDesktopWidget *desktop = NULL;
   QMenu *fileMenu = NULL;
   QMenu *editMenu = NULL;
   QMenu *viewMenu = NULL;
   QMenu *viewClosedDocksMenu = NULL;
   QMenu *toolsMenu = NULL;
   QMenu *updaterMenu = NULL;
   QMenu *helpMenu = NULL;
   QRect desktopRect;
   QDockWidget *thumbnailDock = NULL;
   QDockWidget *thumbnail2Dock = NULL;
   QDockWidget *thumbnail3Dock = NULL;
   QDockWidget *browserAndPlaylistTabDock = NULL;
   QDockWidget *coreSelectionDock = NULL;
   QTabWidget *browserAndPlaylistTabWidget = NULL;
   QWidget *widget = NULL;
   QWidget *browserWidget = NULL;
   QWidget *playlistWidget = NULL;
   QWidget *coreSelectionWidget = NULL;
   QWidget *launchWithWidget = NULL;
   ThumbnailWidget *thumbnailWidget = NULL;
   ThumbnailWidget *thumbnail2Widget = NULL;
   ThumbnailWidget *thumbnail3Widget = NULL;
   QPushButton *browserDownloadsButton = NULL;
   QPushButton *browserUpButton = NULL;
   QPushButton *browserStartButton = NULL;
   ThumbnailLabel *thumbnail = NULL;
   ThumbnailLabel *thumbnail2 = NULL;
   ThumbnailLabel *thumbnail3 = NULL;
   QAction *editSearchAction = NULL;
   QAction *loadCoreAction = NULL;
   QAction *unloadCoreAction = NULL;
   QAction *exitAction = NULL;
   QComboBox *launchWithComboBox = NULL;
   QSettings *qsettings = NULL;
   QListWidget *listWidget = NULL;
   int i = 0;

   if (!handle)
      return NULL;

   handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize());
   handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init());

   desktop = qApp->desktop();
   desktopRect = desktop->availableGeometry();

   mainwindow = handle->window->qtWindow;

   qsettings = mainwindow->settings();

   mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT));
   mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect));

   mainwindow->setWindowTitle("RetroArch");
   mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING);

   listWidget = mainwindow->playlistListWidget();

   widget = new FileDropWidget(mainwindow);
   widget->setObjectName("tableWidget");
   widget->setContextMenuPolicy(Qt::CustomContextMenu);

   QObject::connect(widget, SIGNAL(filesDropped(QStringList)), mainwindow, SLOT(onPlaylistFilesDropped(QStringList)));
   QObject::connect(widget, SIGNAL(deletePressed()), mainwindow, SLOT(deleteCurrentPlaylistItem()));
   QObject::connect(widget, SIGNAL(customContextMenuRequested(const QPoint&)), mainwindow, SLOT(onFileDropWidgetContextMenuRequested(const QPoint&)));

   layout = new QVBoxLayout();
   layout->addWidget(mainwindow->contentTableWidget());
   layout->addWidget(mainwindow->contentGridWidget());

   widget->setLayout(layout);

   mainwindow->setCentralWidget(widget);

   menu = mainwindow->menuBar();

   fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE));

   loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked()));
   loadCoreAction->setShortcut(QKeySequence("Ctrl+L"));

   unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction()));
   unloadCoreAction->setObjectName("unloadCoreAction");
   unloadCoreAction->setEnabled(false);
   unloadCoreAction->setShortcut(QKeySequence("Ctrl+U"));

   exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close()));
   exitAction->setShortcut(QKeySequence::Quit);

   editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT));
   editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus()));
   editSearchAction->setShortcut(QKeySequence::Find);

   viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW));
   viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS));
   viewClosedDocksMenu->setObjectName("viewClosedDocksMenu");

   QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow()));

   viewMenu->addSeparator();
   viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS), mainwindow, SLOT(onIconViewClicked()));
   viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST), mainwindow, SLOT(onListViewClicked()));
   viewMenu->addSeparator();
   viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog()));

   toolsMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_TOOLS));
   updaterMenu = toolsMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ONLINE_UPDATER));
#ifdef Q_OS_WIN
   updaterMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_NIGHTLY), mainwindow, SLOT(updateRetroArchNightly()));
#endif
   helpMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP));
   helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_DOCUMENTATION)), mainwindow, SLOT(showDocs()));
   helpMenu->addAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT)) + "...", mainwindow, SLOT(showAbout()));
   helpMenu->addAction("About Qt...", qApp, SLOT(aboutQt()));

   playlistWidget = new QWidget();
   playlistWidget->setLayout(new QVBoxLayout());
   playlistWidget->setObjectName("playlistWidget");

   playlistWidget->layout()->addWidget(mainwindow->playlistListWidget());

   browserWidget = new QWidget();
   browserWidget->setLayout(new QVBoxLayout());
   browserWidget->setObjectName("browserWidget");

   browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY));
   browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP));
   browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES));

   QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked()));
   QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked()));
   QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked()));

   browserButtonsHBoxLayout = new QHBoxLayout();
   browserButtonsHBoxLayout->addWidget(browserUpButton);
   browserButtonsHBoxLayout->addWidget(browserStartButton);
   browserButtonsHBoxLayout->addWidget(browserDownloadsButton);

   qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout);
   browserWidget->layout()->addWidget(mainwindow->dirTreeView());

   browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget();
   browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget");

   /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too
    * setCoreActions()
    * onTabWidgetIndexChanged()
    * onCurrentListItemChanged()
    */
   browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS));
   browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER));

   browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow);
   browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock");
   browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER));
   browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock);

   browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum));

   thumbnailWidget = new ThumbnailWidget();
   thumbnail2Widget = new ThumbnailWidget();
   thumbnail3Widget = new ThumbnailWidget();

   thumbnailWidget->setLayout(new QVBoxLayout());
   thumbnail2Widget->setLayout(new QVBoxLayout());
   thumbnail3Widget->setLayout(new QVBoxLayout());

   thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

   thumbnail = new ThumbnailLabel();
   thumbnail->setObjectName("thumbnail");

   thumbnail2 = new ThumbnailLabel();
   thumbnail2->setObjectName("thumbnail2");

   thumbnail3 = new ThumbnailLabel();
   thumbnail3->setObjectName("thumbnail3");

   thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

   QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&)));
   QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&)));
   QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&)));

   thumbnailWidget->layout()->addWidget(thumbnail);
   thumbnail2Widget->layout()->addWidget(thumbnail2);
   thumbnail3Widget->layout()->addWidget(thumbnail3);

   thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow);
   thumbnailDock->setObjectName("thumbnailDock");
   thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART));
   thumbnailDock->setWidget(thumbnailWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock);

   thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow);
   thumbnail2Dock->setObjectName("thumbnail2Dock");
   thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN));
   thumbnail2Dock->setWidget(thumbnail2Widget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock);

   thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow);
   thumbnail3Dock->setObjectName("thumbnail3Dock");
   thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT));
   thumbnail3Dock->setWidget(thumbnail3Widget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock);

   mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock);
   mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock);

   /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */
   thumbnailDock->raise();

   coreSelectionWidget = new QWidget();
   coreSelectionWidget->setLayout(new QVBoxLayout());

   launchWithComboBox = mainwindow->launchWithComboBox();

   launchWithWidgetLayout = new QVBoxLayout();

   launchWithWidget = new QWidget();
   launchWithWidget->setLayout(launchWithWidgetLayout);

   coreComboBoxLayout = new QHBoxLayout();

   mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
   mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
   mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));

   coreComboBoxLayout->addWidget(launchWithComboBox);
   coreComboBoxLayout->addWidget(mainwindow->startCorePushButton());
   coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton());
   coreComboBoxLayout->addWidget(mainwindow->runPushButton());
   coreComboBoxLayout->addWidget(mainwindow->stopPushButton());

   mainwindow->stopPushButton()->hide();

   coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1);

   launchWithWidgetLayout->addLayout(coreComboBoxLayout);

   coreSelectionWidget->layout()->addWidget(launchWithWidget);

   coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding));

   coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow);
   coreSelectionDock->setObjectName("coreSelectionDock");
   coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE));
   coreSelectionDock->setWidget(coreSelectionWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock);

   mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
   mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical);
#endif

   /* this should come last */
   mainwindow->resizeThumbnails(true, true, true);

   if (qsettings->contains("all_playlists_list_max_count"))
      mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt());

   if (qsettings->contains("all_playlists_grid_max_count"))
      mainwindow->setAllPlaylistsGridMaxCount(qsettings->value("all_playlists_grid_max_count", 5000).toInt());

   if (qsettings->contains("geometry"))
      if (qsettings->contains("save_geometry"))
         mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray());

   if (qsettings->contains("save_dock_positions"))
      if (qsettings->contains("dock_positions"))
         mainwindow->restoreState(qsettings->value("dock_positions").toByteArray());

   if (qsettings->contains("theme"))
   {
      QString themeStr = qsettings->value("theme").toString();
      MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr);

      if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM)
      {
         QString customThemeFilePath = qsettings->value("custom_theme").toString();

         mainwindow->setCustomThemeFile(customThemeFilePath);
      }

      mainwindow->setTheme(theme);
   }
   else
      mainwindow->setTheme();

   if (qsettings->contains("view_type"))
   {
      QString viewType = qsettings->value("view_type", "list").toString();

      if (viewType == "list")
         mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);
      else if (viewType == "icons")
         mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_ICONS);
      else
         mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);

      /* we set it to the same thing a second time so that m_lastViewType is also equal to the startup view type */
      mainwindow->setCurrentViewType(mainwindow->getCurrentViewType());
   }
   else
      mainwindow->setCurrentViewType(MainWindow::VIEW_TYPE_LIST);

   /* We make sure to hook up the tab widget callback only after the tabs themselves have been added,
    * but before changing to a specific one, to avoid the callback firing before the view type is set.
    */
   QObject::connect(browserAndPlaylistTabWidget, SIGNAL(currentChanged(int)), mainwindow, SLOT(onTabWidgetIndexChanged(int)));

   /* setting the last tab must come after setting the view type */
   if (qsettings->contains("save_last_tab"))
   {
      int lastTabIndex = qsettings->value("last_tab", 0).toInt();

      if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex)
      {
         browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex);
         mainwindow->onTabWidgetIndexChanged(lastTabIndex);
      }
   }
   else
   {
      browserAndPlaylistTabWidget->setCurrentIndex(0);
      mainwindow->onTabWidgetIndexChanged(0);
   }

   for (i = 0; i < listWidget->count() && listWidget->count() > 0; i++)
   {
      /* select the first non-hidden row */
      if (!listWidget->isRowHidden(i))
      {
         listWidget->setCurrentRow(i);
         break;
      }
   }

   return handle;
}
Exemplo n.º 24
0
static void* ui_companion_qt_init(void)
{
   ui_companion_qt_t *handle = (ui_companion_qt_t*)calloc(1, sizeof(*handle));
   MainWindow *mainwindow = NULL;
   QHBoxLayout *browserButtonsHBoxLayout = NULL;
   QVBoxLayout *layout = NULL;
   QVBoxLayout *launchWithWidgetLayout = NULL;
   QHBoxLayout *coreComboBoxLayout = NULL;
   QMenuBar *menu = NULL;
   QDesktopWidget *desktop = NULL;
   QMenu *fileMenu = NULL;
   QMenu *editMenu = NULL;
   QMenu *viewMenu = NULL;
   QMenu *viewClosedDocksMenu = NULL;
   QRect desktopRect;
   QDockWidget *thumbnailDock = NULL;
   QDockWidget *thumbnail2Dock = NULL;
   QDockWidget *thumbnail3Dock = NULL;
   QDockWidget *browserAndPlaylistTabDock = NULL;
   QDockWidget *coreSelectionDock = NULL;
   QTabWidget *browserAndPlaylistTabWidget = NULL;
   QWidget *widget = NULL;
   QWidget *browserWidget = NULL;
   QWidget *playlistWidget = NULL;
   QWidget *coreSelectionWidget = NULL;
   QWidget *launchWithWidget = NULL;
   ThumbnailWidget *thumbnailWidget = NULL;
   ThumbnailWidget *thumbnail2Widget = NULL;
   ThumbnailWidget *thumbnail3Widget = NULL;
   QPushButton *browserDownloadsButton = NULL;
   QPushButton *browserUpButton = NULL;
   QPushButton *browserStartButton = NULL;
   ThumbnailLabel *thumbnail = NULL;
   ThumbnailLabel *thumbnail2 = NULL;
   ThumbnailLabel *thumbnail3 = NULL;
   QAction *editSearchAction = NULL;
   QAction *loadCoreAction = NULL;
   QAction *unloadCoreAction = NULL;
   QAction *exitAction = NULL;
   QComboBox *launchWithComboBox = NULL;
   QSettings *qsettings = NULL;

   if (!handle)
      return NULL;

   handle->app = static_cast<ui_application_qt_t*>(ui_application_qt.initialize());
   handle->window = static_cast<ui_window_qt_t*>(ui_window_qt.init());

   desktop = qApp->desktop();
   desktopRect = desktop->availableGeometry();

   mainwindow = handle->window->qtWindow;

   qsettings = mainwindow->settings();

   mainwindow->resize(qMin(desktopRect.width(), INITIAL_WIDTH), qMin(desktopRect.height(), INITIAL_HEIGHT));
   mainwindow->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mainwindow->size(), desktopRect));

   mainwindow->setWindowTitle("RetroArch");
   mainwindow->setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | GROUPED_DRAGGING);

   widget = new QWidget(mainwindow);
   widget->setObjectName("tableWidget");

   layout = new QVBoxLayout();
   layout->addWidget(mainwindow->contentTableWidget());

   widget->setLayout(layout);

   mainwindow->setCentralWidget(widget);

   menu = mainwindow->menuBar();

   fileMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE));

   loadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_LOAD_CORE), mainwindow, SLOT(onLoadCoreClicked()));
   loadCoreAction->setShortcut(QKeySequence("Ctrl+L"));

   unloadCoreAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_UNLOAD_CORE), mainwindow, SLOT(onUnloadCoreMenuAction()));
   unloadCoreAction->setObjectName("unloadCoreAction");
   unloadCoreAction->setEnabled(false);
   unloadCoreAction->setShortcut(QKeySequence("Ctrl+U"));

   exitAction = fileMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_FILE_EXIT), mainwindow, SLOT(close()));
   exitAction->setShortcut(QKeySequence::Quit);

   editMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT));
   editSearchAction = editMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_EDIT_SEARCH), mainwindow->searchLineEdit(), SLOT(setFocus()));
   editSearchAction->setShortcut(QKeySequence::Find);

   viewMenu = menu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW));
   viewClosedDocksMenu = viewMenu->addMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS));
   viewClosedDocksMenu->setObjectName("viewClosedDocksMenu");

   QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow()));

   viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS), mainwindow->viewOptionsDialog(), SLOT(showDialog()));

   playlistWidget = new QWidget();
   playlistWidget->setLayout(new QVBoxLayout());
   playlistWidget->setObjectName("playlistWidget");

   playlistWidget->layout()->addWidget(mainwindow->playlistListWidget());

   browserWidget = new QWidget();
   browserWidget->setLayout(new QVBoxLayout());
   browserWidget->setObjectName("browserWidget");

   browserDownloadsButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_ASSETS_DIRECTORY));
   browserUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER_UP));
   browserStartButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES));

   QObject::connect(browserDownloadsButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserDownloadsClicked()));
   QObject::connect(browserUpButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserUpClicked()));
   QObject::connect(browserStartButton, SIGNAL(clicked()), mainwindow, SLOT(onBrowserStartClicked()));

   browserButtonsHBoxLayout = new QHBoxLayout();
   browserButtonsHBoxLayout->addWidget(browserUpButton);
   browserButtonsHBoxLayout->addWidget(browserStartButton);
   browserButtonsHBoxLayout->addWidget(browserDownloadsButton);

   qobject_cast<QVBoxLayout*>(browserWidget->layout())->addLayout(browserButtonsHBoxLayout);
   browserWidget->layout()->addWidget(mainwindow->dirTreeView());

   browserAndPlaylistTabWidget = mainwindow->browserAndPlaylistTabWidget();
   browserAndPlaylistTabWidget->setObjectName("browserAndPlaylistTabWidget");

   /* Several functions depend on the same tab title strings here, so if you change these, make sure to change those too
    * setCoreActions()
    * onTabWidgetIndexChanged()
    * onCurrentListItemChanged()
    */
   browserAndPlaylistTabWidget->addTab(playlistWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS));
   browserAndPlaylistTabWidget->addTab(browserWidget, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_FILE_BROWSER));

   browserAndPlaylistTabDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER), mainwindow);
   browserAndPlaylistTabDock->setObjectName("browserAndPlaylistTabDock");
   browserAndPlaylistTabDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   browserAndPlaylistTabDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER));
   browserAndPlaylistTabDock->setWidget(browserAndPlaylistTabWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(browserAndPlaylistTabDock->property("default_area").toInt()), browserAndPlaylistTabDock);

   browserButtonsHBoxLayout->addItem(new QSpacerItem(browserAndPlaylistTabWidget->tabBar()->width(), 20, QSizePolicy::Expanding, QSizePolicy::Minimum));

   thumbnailWidget = new ThumbnailWidget();
   thumbnail2Widget = new ThumbnailWidget();
   thumbnail3Widget = new ThumbnailWidget();

   thumbnailWidget->setLayout(new QVBoxLayout());
   thumbnail2Widget->setLayout(new QVBoxLayout());
   thumbnail3Widget->setLayout(new QVBoxLayout());

   thumbnailWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail2Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail3Widget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

   thumbnail = new ThumbnailLabel();
   thumbnail->setObjectName("thumbnail");

   thumbnail2 = new ThumbnailLabel();
   thumbnail2->setObjectName("thumbnail2");

   thumbnail3 = new ThumbnailLabel();
   thumbnail3->setObjectName("thumbnail3");

   thumbnail->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
   thumbnail3->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

   QObject::connect(mainwindow, SIGNAL(thumbnailChanged(const QPixmap&)), thumbnail, SLOT(setPixmap(const QPixmap&)));
   QObject::connect(mainwindow, SIGNAL(thumbnail2Changed(const QPixmap&)), thumbnail2, SLOT(setPixmap(const QPixmap&)));
   QObject::connect(mainwindow, SIGNAL(thumbnail3Changed(const QPixmap&)), thumbnail3, SLOT(setPixmap(const QPixmap&)));

   thumbnailWidget->layout()->addWidget(thumbnail);
   thumbnail2Widget->layout()->addWidget(thumbnail2);
   thumbnail3Widget->layout()->addWidget(thumbnail3);

   thumbnailDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART), mainwindow);
   thumbnailDock->setObjectName("thumbnailDock");
   thumbnailDock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnailDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART));
   thumbnailDock->setWidget(thumbnailWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnailDock->property("default_area").toInt()), thumbnailDock);

   thumbnail2Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN), mainwindow);
   thumbnail2Dock->setObjectName("thumbnail2Dock");
   thumbnail2Dock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnail2Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_TITLE_SCREEN));
   thumbnail2Dock->setWidget(thumbnail2Widget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail2Dock->property("default_area").toInt()), thumbnail2Dock);

   thumbnail3Dock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT), mainwindow);
   thumbnail3Dock->setObjectName("thumbnail3Dock");
   thumbnail3Dock->setProperty("default_area", Qt::RightDockWidgetArea);
   thumbnail3Dock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT));
   thumbnail3Dock->setWidget(thumbnail3Widget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(thumbnail3Dock->property("default_area").toInt()), thumbnail3Dock);

   mainwindow->tabifyDockWidget(thumbnailDock, thumbnail2Dock);
   mainwindow->tabifyDockWidget(thumbnailDock, thumbnail3Dock);

   /* when tabifying the dock widgets, the last tab added is selected by default, so we need to re-select the first tab */
   thumbnailDock->raise();

   coreSelectionWidget = new QWidget();
   coreSelectionWidget->setLayout(new QVBoxLayout());

   launchWithComboBox = mainwindow->launchWithComboBox();

   launchWithWidgetLayout = new QVBoxLayout();

   launchWithWidget = new QWidget();
   launchWithWidget->setLayout(launchWithWidgetLayout);

   coreComboBoxLayout = new QHBoxLayout();

   mainwindow->runPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
   mainwindow->stopPushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
   mainwindow->startCorePushButton()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));

   coreComboBoxLayout->addWidget(launchWithComboBox);
   coreComboBoxLayout->addWidget(mainwindow->startCorePushButton());
   coreComboBoxLayout->addWidget(mainwindow->coreInfoPushButton());
   coreComboBoxLayout->addWidget(mainwindow->runPushButton());
   coreComboBoxLayout->addWidget(mainwindow->stopPushButton());

   mainwindow->stopPushButton()->hide();

   coreComboBoxLayout->setStretchFactor(launchWithComboBox, 1);

   launchWithWidgetLayout->addLayout(coreComboBoxLayout);

   coreSelectionWidget->layout()->addWidget(launchWithWidget);

   coreSelectionWidget->layout()->addItem(new QSpacerItem(20, browserAndPlaylistTabWidget->height(), QSizePolicy::Minimum, QSizePolicy::Expanding));

   coreSelectionDock = new QDockWidget(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE), mainwindow);
   coreSelectionDock->setObjectName("coreSelectionDock");
   coreSelectionDock->setProperty("default_area", Qt::LeftDockWidgetArea);
   coreSelectionDock->setProperty("menu_text", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CORE));
   coreSelectionDock->setWidget(coreSelectionWidget);

   mainwindow->addDockWidget(static_cast<Qt::DockWidgetArea>(coreSelectionDock->property("default_area").toInt()), coreSelectionDock);

   mainwindow->splitDockWidget(browserAndPlaylistTabDock, coreSelectionDock, Qt::Vertical);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
   mainwindow->resizeDocks(QList<QDockWidget*>() << coreSelectionDock, QList<int>() << 1, Qt::Vertical);
#endif

   /* this should come last */
   mainwindow->resizeThumbnails(true, true, true);

   if (qsettings->contains("geometry"))
      if (qsettings->contains("save_geometry"))
         mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray());

   if (qsettings->contains("save_dock_positions"))
      if (qsettings->contains("dock_positions"))
         mainwindow->restoreState(qsettings->value("dock_positions").toByteArray());

   if (qsettings->contains("save_last_tab"))
   {
      if (qsettings->contains("last_tab"))
      {
         int lastTabIndex = qsettings->value("last_tab", 0).toInt();

         if (lastTabIndex >= 0 && browserAndPlaylistTabWidget->count() > lastTabIndex)
            browserAndPlaylistTabWidget->setCurrentIndex(lastTabIndex);
      }
   }

   if (qsettings->contains("theme"))
   {
      QString themeStr = qsettings->value("theme").toString();
      MainWindow::Theme theme = mainwindow->getThemeFromString(themeStr);

      if (qsettings->contains("custom_theme") && theme == MainWindow::THEME_CUSTOM)
      {
         QString customThemeFilePath = qsettings->value("custom_theme").toString();

         mainwindow->setCustomThemeFile(customThemeFilePath);
      }

      mainwindow->setTheme(theme);
   }
   else
      mainwindow->setTheme();

   return handle;
}
Exemplo n.º 25
0
	void setupUi(QDialog *MemberEditDialog) {
		p = MemberEditDialog;

		mainWidget             = new QWidget(MemberEditDialog);
		horizontalLayout       = new QHBoxLayout(mainWidget);
		tabWidget              = new QTabWidget(mainWidget);
		generalTab             = new QWidget();
		generalHLayout         = new QHBoxLayout(generalTab);
		formWidget             = new QWidget(generalTab);
		formTab1LeftLayout     = new QFormLayout(formWidget);
		titleLabel             = new QLabel(formWidget);
		firstNameLabel         = new QLabel(formWidget);
		firstNameLineEdit      = new QLineEdit(formWidget);
		lastNameLabel          = new QLabel(formWidget);
		lastNameLineEdit       = new QLineEdit(formWidget);
		streetLabel            = new QLabel(formWidget);
		zipLabel               = new QLabel(formWidget);
		streetHorizontalWidget = new QWidget(formWidget);
		streetHLayout          = new QHBoxLayout(streetHorizontalWidget);
		streetLineEdit         = new QLineEdit(streetHorizontalWidget);
		numberLabel            = new QLabel(streetHorizontalWidget);
		numberLineEdit         = new QLineEdit(streetHorizontalWidget);
		cityHorizontalWidget   = new QWidget(formWidget);
		cityHLayout            = new QHBoxLayout(cityHorizontalWidget);
		zipLineEdit            = new QLineEdit(cityHorizontalWidget);
		cityLabel              = new QLabel(cityHorizontalWidget);
		cityLineEdit           = new QLineEdit(cityHorizontalWidget);
		titleHorizontalWidget  = new QWidget(formWidget);
		titleHLayout           = new QHBoxLayout(titleHorizontalWidget);
		comboBox               = new QComboBox(titleHorizontalWidget);
		titleExtLabel          = new QLabel(titleHorizontalWidget);
		titleExtLineEdit       = new QLineEdit(titleHorizontalWidget);
		formTab1Right          = new QWidget(generalTab);
		formTab1RightLayout    = new QFormLayout(formTab1Right);
		phoneLabel             = new QLabel(formTab1Right);
		phoneEdit              = new QLineEdit(formTab1Right);
		cellLabel              = new QLabel(formTab1Right);
		cellEdit               = new QLineEdit(formTab1Right);
		emailLabel             = new QLabel(formTab1Right);
		emailEdit              = new QLineEdit(formTab1Right);
		maritalLabel           = new QLabel(formTab1Right);
		maritalCBox            = new QComboBox(formTab1Right);
		accountTab             = new QWidget();
		accountVLayout         = new QVBoxLayout(accountTab);
		tableView              = new QTableView(accountTab);
		tab2BottomLayout       = new QHBoxLayout();
		formTab2BottomLayout   = new QFormLayout();
		ibanLabel              = new QLabel(accountTab);
		ibanLineEdit           = new QLineEdit(accountTab);
		bicLabel               = new QLabel(accountTab);
		bicLineEdit            = new QLineEdit(accountTab);
		ownerLabel             = new QLabel(accountTab);
		ownerLineEdit          = new QLineEdit(accountTab);
		noteLabel              = new QLabel(accountTab);
		noteLineEdit           = new QLineEdit(accountTab);
		buttonsTab2BottomLayout       = new QVBoxLayout();
		addButton             = new QPushButton(accountTab);
		editButton           = new QPushButton(accountTab);
		deleteButton           = new QPushButton(accountTab);
		verticalLayout         = new QVBoxLayout();
		okButton               = new QPushButton(mainWidget);
		applyButton            = new QPushButton(mainWidget);
		verticalSpacer         = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
		leaveButton            = new QPushButton(mainWidget);
		verticalSpacer_2       = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
		cancelButton           = new QPushButton(mainWidget);

		// # layout definitions #

		// tabs on left, buttons on the right
		horizontalLayout->addWidget(tabWidget);
		horizontalLayout->addLayout(verticalLayout);

		// set up buttons on right
    verticalLayout->addWidget(okButton);
    verticalLayout->addWidget(applyButton);
    verticalLayout->addItem(verticalSpacer);
    verticalLayout->addWidget(leaveButton);
    verticalLayout->addItem(verticalSpacer_2);
    verticalLayout->addWidget(cancelButton);

		// set up tabs
		tabWidget->addTab(generalTab, QString());
		tabWidget->addTab(accountTab, QString());
		tabWidget->setCurrentIndex(0);

		// set up general tab
		generalHLayout->addWidget(formWidget);
		generalHLayout->addWidget(formTab1Right);

		// set up account tab
		accountVLayout->addWidget(tableView);
		accountVLayout->addLayout(tab2BottomLayout);

		accountVLayout->setContentsMargins(0, 0, 0, 0);

		// set up lazout of bottom part of account tab
		// form and buttons to add entries to table in a h-box
		tab2BottomLayout->addLayout(formTab2BottomLayout);
		tab2BottomLayout->addLayout(buttonsTab2BottomLayout);

		// buttons column of bottom part of account tab
		buttonsTab2BottomLayout->addWidget(addButton);
		buttonsTab2BottomLayout->addWidget(editButton);
		buttonsTab2BottomLayout->addWidget(deleteButton);


		// ## forms of general tab / general personal data ##

		// left side - personal data, address, etc.
		formTab1LeftLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
		formTab1LeftLayout->setWidget(0, QFormLayout::LabelRole, titleLabel);
		formTab1LeftLayout->setWidget(0, QFormLayout::FieldRole, titleHorizontalWidget);
		formTab1LeftLayout->setWidget(1, QFormLayout::LabelRole, firstNameLabel);
		formTab1LeftLayout->setWidget(1, QFormLayout::FieldRole, firstNameLineEdit);
		formTab1LeftLayout->setWidget(2, QFormLayout::LabelRole, lastNameLabel);
		formTab1LeftLayout->setWidget(2, QFormLayout::FieldRole, lastNameLineEdit);
		formTab1LeftLayout->setWidget(3, QFormLayout::LabelRole, streetLabel);
		formTab1LeftLayout->setWidget(3, QFormLayout::FieldRole, streetHorizontalWidget);
		formTab1LeftLayout->setWidget(4, QFormLayout::LabelRole, zipLabel);
		formTab1LeftLayout->setWidget(4, QFormLayout::FieldRole, cityHorizontalWidget);

		// right side - phone, email,
		formTab1RightLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
		formTab1RightLayout->setWidget(0, QFormLayout::LabelRole, phoneLabel);  // phone
		formTab1RightLayout->setWidget(0, QFormLayout::FieldRole, phoneEdit);
		formTab1RightLayout->setWidget(1, QFormLayout::LabelRole, cellLabel);     // mobile / cell phone number
		formTab1RightLayout->setWidget(1, QFormLayout::FieldRole, cellEdit);
		formTab1RightLayout->setWidget(2, QFormLayout::LabelRole, emailLabel); // email
		formTab1RightLayout->setWidget(2, QFormLayout::FieldRole, emailEdit);
		formTab1RightLayout->setWidget(3, QFormLayout::LabelRole, maritalLabel); // marital status
		formTab1RightLayout->setWidget(3, QFormLayout::FieldRole, maritalCBox);

		// form on bottom of account tab
		formTab2BottomLayout->setWidget(0, QFormLayout::LabelRole, ibanLabel);
		formTab2BottomLayout->setWidget(0, QFormLayout::FieldRole, ibanLineEdit);
		formTab2BottomLayout->setWidget(1, QFormLayout::LabelRole, bicLabel);
		formTab2BottomLayout->setWidget(1, QFormLayout::FieldRole, bicLineEdit);
		formTab2BottomLayout->setWidget(2, QFormLayout::LabelRole, ownerLabel);
		formTab2BottomLayout->setWidget(2, QFormLayout::FieldRole, ownerLineEdit);
		formTab2BottomLayout->setWidget(3, QFormLayout::LabelRole, noteLabel);
		formTab2BottomLayout->setWidget(3, QFormLayout::FieldRole, noteLineEdit);

		// street and number next to each other in one cell
		// so put them in a hbox and that into the form
		streetHLayout->addWidget(streetLineEdit);
		streetHLayout->addWidget(numberLabel);
		streetHLayout->addWidget(numberLineEdit);
		streetHLayout->setContentsMargins(0, 0, 0, 0);
		streetHLayout->setStretch(0, 5);
		streetHLayout->setStretch(2, 1);

		// zip and city in one cell like above
		cityHLayout->addWidget(zipLineEdit);
		cityHLayout->addWidget(cityLabel);
		cityHLayout->addWidget(cityLineEdit);
		cityHLayout->setContentsMargins(0, 0, 0, 0);

		// title and titleext like above
		titleHLayout->addWidget(comboBox);
		titleHLayout->addWidget(titleExtLabel);
		titleHLayout->addWidget(titleExtLineEdit);
		titleHLayout->setContentsMargins(0, 0, 0, 0);

		// zip codes have only 5 digits, also define appropriate size
		zipLineEdit->setMaxLength(5);
		zipLineEdit->setMaximumSize(QSize(80, 16777215));


		// initial siye of dialog. TODO: Save in conf on quit. Restore here.
		MemberEditDialog->resize(1200, 700);
		updateGeometry();


		retranslateUi(MemberEditDialog);

		QMetaObject::connectSlotsByName(MemberEditDialog);
		if (MemberEditDialog->objectName().isEmpty())
			MemberEditDialog->setObjectName(QStringLiteral("MemberEditDialog"));

		mainWidget->setObjectName(QStringLiteral("mainWidget"));
		horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
		tabWidget->setObjectName(QStringLiteral("tabWidget"));
		generalTab->setObjectName(QStringLiteral("generalTab"));
		generalHLayout->setObjectName(QStringLiteral("generalHLayout"));
		formWidget->setObjectName(QStringLiteral("formWidget"));
		formTab1LeftLayout->setObjectName(QStringLiteral("formTab1LeftLayout"));
		titleLabel->setObjectName(QStringLiteral("titleLabel"));
		firstNameLabel->setObjectName(QStringLiteral("firstNameLabel"));
		firstNameLineEdit->setObjectName(QStringLiteral("firstNameLineEdit"));
		lastNameLabel->setObjectName(QStringLiteral("lastNameLabel"));
		lastNameLineEdit->setObjectName(QStringLiteral("lastNameLineEdit"));
		streetLabel->setObjectName(QStringLiteral("streetLabel"));
		zipLabel->setObjectName(QStringLiteral("zipLabel"));
		streetHorizontalWidget->setObjectName(QStringLiteral("streetHorizontalWidget"));
		streetHLayout->setObjectName(QStringLiteral("streetHLayout"));
		streetLineEdit->setObjectName(QStringLiteral("streetLineEdit"));
		numberLabel->setObjectName(QStringLiteral("numberLabel"));
		numberLineEdit->setObjectName(QStringLiteral("numberLineEdit"));
		cityHorizontalWidget->setObjectName(QStringLiteral("cityHorizontalWidget"));
		cityHLayout->setObjectName(QStringLiteral("cityHLayout"));
		zipLineEdit->setObjectName(QStringLiteral("zipLineEdit"));
		cityLabel->setObjectName(QStringLiteral("cityLabel"));
		cityLineEdit->setObjectName(QStringLiteral("cityLineEdit"));
		titleHorizontalWidget->setObjectName(QStringLiteral("titleHorizontalWidget"));
		titleHLayout->setObjectName(QStringLiteral("titleHLayout"));
		comboBox->setObjectName(QStringLiteral("comboBox"));
		titleExtLabel->setObjectName(QStringLiteral("titleExtLabel"));
		titleExtLineEdit->setObjectName(QStringLiteral("titleExtLineEdit"));
		formTab1Right->setObjectName(QStringLiteral("formTab1Right"));
		formTab1RightLayout->setObjectName(QStringLiteral("formTab1RightLayout"));
		phoneLabel->setObjectName(QStringLiteral("phoneLabel"));
		phoneEdit->setObjectName(QStringLiteral("phoneEdit"));
		cellLabel->setObjectName(QStringLiteral("cellLabel"));
		cellEdit->setObjectName(QStringLiteral("cellEdit"));
		emailLabel->setObjectName(QStringLiteral("emailLabel"));
		emailEdit->setObjectName(QStringLiteral("emailEdit"));
		maritalLabel->setObjectName(QStringLiteral("maritalLabel"));
		maritalCBox->setObjectName(QStringLiteral("maritalCBox"));
		accountTab->setObjectName(QStringLiteral("accountTab"));
		accountVLayout->setObjectName(QStringLiteral("accountVLayout"));
		tableView->setObjectName(QStringLiteral("tableView"));
		tab2BottomLayout->setObjectName(QStringLiteral("tab2BottomLayout"));
		formTab2BottomLayout->setObjectName(QStringLiteral("formTab2BottomLayout"));
		ibanLabel->setObjectName(QStringLiteral("ibanLabel"));
		ibanLineEdit->setObjectName(QStringLiteral("ibanLineEdit"));
		bicLabel->setObjectName(QStringLiteral("bicLabel"));
		bicLineEdit->setObjectName(QStringLiteral("bicLineEdit"));
		ownerLabel->setObjectName(QStringLiteral("ownerLabel"));
		ownerLineEdit->setObjectName(QStringLiteral("ownerLineEdit"));
		noteLabel->setObjectName(QStringLiteral("noteLabel"));
		noteLineEdit->setObjectName(QStringLiteral("noteLineEdit"));
		buttonsTab2BottomLayout->setObjectName(QStringLiteral("buttonsTab2BottomLayout"));
		addButton->setObjectName(QStringLiteral("addButton"));
		editButton->setObjectName(QStringLiteral("editButton"));
		deleteButton->setObjectName(QStringLiteral("deleteButton"));
		verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
		okButton->setObjectName(QStringLiteral("okButton"));
		applyButton->setObjectName(QStringLiteral("applyButton"));
		leaveButton->setObjectName(QStringLiteral("leaveButton"));
		cancelButton->setObjectName(QStringLiteral("cancelButton"));



	} // setupUi
Exemplo n.º 26
0
HomescreenSettings::HomescreenSettings(QWidget* parent, Qt::WFlags fl)
    : QDialog( parent, fl)
{
    setWindowTitle(tr("Homescreen"));

    connect( qApp, SIGNAL(appMessage(QString,QByteArray)),
            this, SLOT(appMessage(QString,QByteArray)) );
   
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    QTabWidget *tabWidget = new QTabWidget(this);
    
    //appearance tab
    QWidget *appearance = new QWidget;
    QScrollArea *appearanceWrapper = new QScrollArea;
    appearanceWrapper->setFocusPolicy(Qt::NoFocus);
    appearanceWrapper->setFrameStyle(QFrame::NoFrame);
    appearanceWrapper->setWidget(appearance);
    appearanceWrapper->setWidgetResizable(true);
    appearanceWrapper->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 
    QFormLayout *appearanceLayout = new QFormLayout(appearance);
    
    QSettings config("Trolltech", "qpe");
    config.beginGroup( "HomeScreen" );
    QString hsImgName = config.value("HomeScreenPicture").toString();
    int hsDisplayMode = config.value("HomeScreenPictureMode", 0).toInt();

    image = new QPushButton();
    image->setIconSize(QSize(50,75));
    image->setMinimumHeight(80);

    imageMode = new QComboBox;
    imageMode->addItem(tr("Scale & Crop"));
    imageMode->addItem(tr("Stretch"));
    imageMode->addItem(tr("Tile"));
    imageMode->addItem(tr("Center"));
    imageMode->addItem(tr("Scale"));
    imageMode->setCurrentIndex(hsDisplayMode);
    
    hsImage = QContent(hsImgName);
    if (!hsImage.isValid()) {
        image->setText(tr("No image"));
        imageMode->setVisible(false);
    }
    else {
        image->setIcon(QIcon(hsImage.fileName()));
    }
    connect( image, SIGNAL(clicked()), this, SLOT(editPhoto()) );

    QVBoxLayout *imageLayout = new QVBoxLayout;
    imageLayout->setContentsMargins(0, 0, 0, 0);
    imageLayout->setSpacing(0);
    imageLayout->addWidget(image);
    imageLayout->addWidget(imageMode);
    appearanceLayout->addRow(tr("Image"), imageLayout);
    
    time = new QCheckBox(tr("Time"));
    date = new QCheckBox(tr("Date"));
    op = new QCheckBox(tr("Operator"));
    profile = new QCheckBox(tr("Profile"));
    location = new QCheckBox(tr("Location"));
    
    time->setCheckState(config.value("ShowTime", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    date->setCheckState(config.value("ShowDate", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    op->setCheckState(config.value("ShowOperator", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    profile->setCheckState(config.value("ShowProfile", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    location->setCheckState(config.value("ShowLocation", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    
    QVBoxLayout *checkLayout = new QVBoxLayout;
    checkLayout->setContentsMargins(0, 0, 0, 0);
    checkLayout->setSpacing(0);
    checkLayout->addWidget(time);
    checkLayout->addWidget(date);
    checkLayout->addWidget(op);
    checkLayout->addWidget(profile);
    checkLayout->addWidget(location);
    
    appearanceLayout->addRow(tr("Display"), checkLayout);
    
    //idle tab
    QWidget *idle = new QWidget;
    QVBoxLayout *idleLayout = new QVBoxLayout(idle);
    
    QLabel *label = new QLabel(tr("Return to homescreen:"));
    
    QHBoxLayout *h1 = new QHBoxLayout;
    QHBoxLayout *h2 = new QHBoxLayout;
    QHBoxLayout *h3 = new QHBoxLayout;
    
    homeScreen = new QComboBox;
    homeScreen->addItem(tr("On display off"));
    homeScreen->addItem(tr("On suspend"));
    homeScreen->addItem(tr("Never"));
    label->setBuddy(homeScreen);
    connect(homeScreen, SIGNAL(activated(int)), this, SLOT(homeScreenActivated(int)));

    QString showHomeScreen = config.value("ShowHomeScreen", "Never").toString();
    if (showHomeScreen == "DisplayOff")
        homeScreen->setCurrentIndex(0);
    else if (showHomeScreen == "Suspend")
        homeScreen->setCurrentIndex(1);
    else
        homeScreen->setCurrentIndex(2);

    lock = new QCheckBox(tr("Lock keys"));
    lock->setCheckState(config.value("AutoKeyLock", false).toBool() ? Qt::Checked : Qt::Unchecked);
    lock->setEnabled(homeScreen->currentIndex() == homeScreen->count()-1 ? false : true);

    powerNote = new QLabel;
    powerNote->setWordWrap( true );
    QFont font = QApplication::font();
    font.setItalic( true );
    powerNote->setFont( font );
    homeScreenActivated( homeScreen->currentIndex() );

    screenSaver_vsi = new QValueSpaceItem( "/Hardware/ScreenSaver/State", this );
    connect( screenSaver_vsi, SIGNAL(contentsChanged()), this, SLOT(homeScreenActivated()) );
    h1->addSpacing(20);
    h1->addWidget(homeScreen);
    h2->addSpacing(20);
    h2->addWidget(lock);
    h3->addSpacing(20);
    h3->addWidget(powerNote);
    
    idleLayout->addWidget(label);
    idleLayout->addLayout(h1);
    idleLayout->addLayout(h2);
    idleLayout->addLayout(h3);
    idleLayout->addStretch(1);
    
    //secondary screen tab
    //TODO: reduce amount of duplicated code between tabs
    if (QApplication::desktop()->numScreens() > 1) {
        QWidget *secondary = new QWidget;
        QScrollArea *secondaryWrapper = new QScrollArea;
        secondaryWrapper->setFocusPolicy(Qt::NoFocus);
        secondaryWrapper->setFrameStyle(QFrame::NoFrame);
        secondaryWrapper->setWidget(secondary);
        secondaryWrapper->setWidgetResizable(true);
        secondaryWrapper->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 
        QFormLayout *secondaryLayout = new QFormLayout(secondary);
        
        hsImgName = config.value("SecondaryHomeScreenPicture").toString();
        hsDisplayMode = config.value("SecondaryHomeScreenPictureMode", 0).toInt();
            
        secondaryImage = new QPushButton();
        secondaryImage->setIconSize(QSize(50,75));
        secondaryImage->setMinimumHeight(80);

        secondaryImageMode = new QComboBox;
        secondaryImageMode->addItem(tr("Scale & Crop"));
        secondaryImageMode->addItem(tr("Stretch"));
        secondaryImageMode->addItem(tr("Tile"));
        secondaryImageMode->addItem(tr("Center"));
        secondaryImageMode->addItem(tr("Scale"));
        secondaryImageMode->setCurrentIndex(hsDisplayMode);
        
        secondaryHsImage = QContent(hsImgName);
        if (!secondaryHsImage.isValid()) {
            secondaryImage->setText(tr("No image"));
            secondaryImageMode->setVisible(false);
        }
        else {
            secondaryImage->setIcon(QIcon(secondaryHsImage.fileName()));
        }
        connect( secondaryImage, SIGNAL(clicked()), this, SLOT(editSecondaryPhoto()) );
    
        QVBoxLayout *secondaryImageLayout = new QVBoxLayout;
        secondaryImageLayout->setContentsMargins(0, 0, 0, 0);
        secondaryImageLayout->setSpacing(0);
        secondaryImageLayout->addWidget(secondaryImage);
        secondaryImageLayout->addWidget(secondaryImageMode);
        secondaryLayout->addRow(tr("Image"), secondaryImageLayout);
        
        tabWidget->addTab(secondaryWrapper, tr("Secondary","Secondary Display"));
    }
    
    tabWidget->insertTab(0, appearanceWrapper, tr("Appearance"));
    tabWidget->insertTab(1, idle, tr("Idle"));
    tabWidget->setCurrentIndex(0);
    
    layout->addWidget(tabWidget);

    QDrmContentPlugin::initialize();
}
Exemplo n.º 27
0
int drv_tabwidget(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QTabWidget *self = (QTabWidget*)head->native;
    switch (drvid) {
    case TABWIDGET_INIT: {
        drvNewObj(a0,new QTabWidget);
        break;
    }
    case TABWIDGET_ADDTAB: {
        self->addTab(drvGetWidget(a1),drvGetString(a2));
        break;
    }
    case TABWIDGET_CLEAR: {
        self->clear();
        break;
    }
    case TABWIDGET_COUNT: {
        drvSetInt(a1,self->count());
        break;
    }
    case TABWIDGET_CURRENTINDEX: {
        drvSetInt(a1,self->currentIndex());
        break;
    }
    case TABWIDGET_CURRENTWIDGET: {
        drvSetHandle(a1,self->currentWidget());
        break;
    }
    case TABWIDGET_SETCURRENTINDEX: {
        self->setCurrentIndex(drvGetInt(a1));
        break;
    }
    case TABWIDGET_SETCURRENTWIDGET: {
        self->setCurrentWidget(drvGetWidget(a1));
        break;
    }
    case TABWIDGET_INDEXOF: {
        drvSetInt(a2,self->indexOf(drvGetWidget(a1)));
        break;
    }
    case TABWIDGET_INSERTTAB: {
        self->insertTab(drvGetInt(a1),drvGetWidget(a2),drvGetString(a3));
        break;
    }
    case TABWIDGET_REMOVETAB: {
        self->removeTab(drvGetInt(a1));
        break;
    }
    case TABWIDGET_SETTABTEXT: {
        self->setTabText(drvGetInt(a1),drvGetString(a2));
        break;
    }
    case TABWIDGET_SETTABTOOLTIP: {
        self->setTabToolTip(drvGetInt(a1),drvGetString(a2));
        break;
    }
    case TABWIDGET_TABTEXT: {
        drvSetString(a2,self->tabText(drvGetInt(a1)));
        break;
    }
    case TABWIDGET_TABTOOLTIP: {
        drvSetString(a2,self->tabToolTip(drvGetInt(a1)));
        break;
    }
    case TABWIDGET_WIDGETOF: {
        drvSetHandle(a2,self->widget(drvGetInt(a1)));
        break;
    }
    case TABWIDGET_ONCURRENTCHANGED: {
        QObject::connect(self,SIGNAL(currentChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
Exemplo n.º 28
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    browser_ = new WebBrowser;
    browser_->loadSettings();
    browser_->GoHome();
    //setCentralWidget(browser_);
    // PESTAÑAS
    QTabWidget *tabWidgetMainWindow = new QTabWidget(this);
    tabWidgetMainWindow->setMinimumSize(800,600);
    tabWidgetMainWindow->addTab(browser_, "Pestaña 1");
    tabWidgetMainWindow->addTab(new WebBrowser, "Pestaña 2");
    tabWidgetMainWindow->setCurrentIndex(1);
    tabWidgetMainWindow->show();
    setCentralWidget(tabWidgetMainWindow);

    zoomVar = 1;    // inicialización del zoom

    // inicializamos los menus
    mainMenu_ = new QMenuBar(this);
    setMenuBar(mainMenu_);

    mnuArchivo_ = new QMenu(tr("&Archivo"), this);
    //mainMenu_ -> addMenu(mnuArchivo_);

    mnuEditar_ = new QMenu(tr("&Editar"), this);
    //mainMenu_ -> addMenu(mnuEditar_);

    mnuVer_ = new QMenu(tr("&Ver"), this);
    mainMenu_ -> addMenu(mnuVer_);
    actPlusZoom = new QAction(tr("&Aumentar zoom"), this);
    actPlusZoom -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus));
    mnuVer_->addAction(actPlusZoom);
    connect(actPlusZoom, SIGNAL(triggered()), this, SLOT(setPlusZoom()));

    actMinusZoom_ = new QAction(tr("&Disminuir zoom"), this);
    actMinusZoom_ -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus));
    mnuVer_->addAction(actMinusZoom_);
    connect(actMinusZoom_, SIGNAL(triggered()), this, SLOT(setMinusZoom()));


    mnuMarcadores_ = new QMenu(tr("&Marcadores"), this);
    mainMenu_ -> addMenu(mnuMarcadores_);
    actAddBookmark_ = new QAction(tr("&Añadir a marcadores"), this);
    actAddBookmark_ -> setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_O));
    mnuMarcadores_->addAction(actAddBookmark_);
    connect(actAddBookmark_, SIGNAL(triggered()), this, SLOT(addMarcador()));

    mnuHerramientas_ = new QMenu(tr("&Herramientas"), this);
    mainMenu_ -> addMenu(mnuHerramientas_);
    actSetHomepage_ = new QAction(tr("Establecer como pagina principal"), this);
    mnuHerramientas_->addAction(actSetHomepage_);
    connect(actSetHomepage_, SIGNAL(triggered()), browser_, SLOT(setHomepage()));

    mnuHistorial_ = new QMenu(tr("&Historial"), this);
    mainMenu_ -> addMenu(mnuHistorial_);
    actDeleteHistory_ = new QAction(tr("&Borrar el historial"), this);
    actDeleteHistory_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
    mnuHistorial_->addAction(actDeleteHistory_);
    connect(actDeleteHistory_,  SIGNAL(triggered()), this, SLOT(deleteHistory()));

    showHistory();

    readBookmarkFile();
    for (int i = 0; i < bookmarkList.size(); ++i) {
        QAction* tmp = new QAction(tr(bookmarkList.at(i).toLocal8Bit().constData()), this);
        mnuMarcadores_->addAction(tmp);
        connect(tmp,SIGNAL(triggered()),this,SLOT(PulsarMarcador()));
    }
}
Exemplo n.º 29
0
SingleActionEditor::SingleActionEditor(QWidget * par,ActionEditor * ed)
: QWidget(par)
{
	m_pActionEditor = ed;
	m_pActionData = 0;

	QGridLayout * g = new QGridLayout(this);

	QLabel * l = new QLabel(__tr2qs_ctx("Name:","editor"),this);
	g->addWidget(l,0,0);
	m_pNameEdit = new QLineEdit(this);
	g->addWidget(m_pNameEdit,0,1);
	m_pNameEdit->setToolTip(__tr2qs_ctx("Internal unique name for the action","editor"));

	l = new QLabel(__tr2qs_ctx("Label:","editor"),this);
	g->addWidget(l,1,0);
	m_pVisibleNameEdit = new QLineEdit(this);
	g->addWidget(m_pVisibleNameEdit,1,1);
	m_pVisibleNameEdit->setToolTip(__tr2qs_ctx("Visible name for this action.<br>This string will be displayed to the user so it is a good idea to use $tr() here","editor"));


	QTabWidget * tw = new QTabWidget(this);
	g->addWidget(tw,2,0,1,2);

	// code tab
	QWidget * tab = new QWidget(tw);
	QGridLayout * gl = new QGridLayout(tab);

	m_pScriptEditor = KviScriptEditor::createInstance(tab);
	gl->addWidget(m_pScriptEditor,0,0);
	m_pScriptEditor->setToolTip(__tr2qs_ctx("Action code","editor"));

	tw->addTab(tab,__tr2qs_ctx("Code","editor"));

	// properties tab
	tab = new QWidget(tw);
	gl = new QGridLayout(tab);

	l = new QLabel(__tr2qs_ctx("Category:","editor"),tab);
	gl->addWidget(l,0,0);
	m_pCategoryCombo = new QComboBox(tab);
	gl->addWidget(m_pCategoryCombo,0,1,1,3);
	m_pCategoryCombo->setToolTip(__tr2qs_ctx("Choose the category that best fits for this action","editor"));

	l = new QLabel(__tr2qs_ctx("Description:","editor"),tab);
	gl->addWidget(l,1,0);
	m_pDescriptionEdit = new QLineEdit(tab);
	gl->addWidget(m_pDescriptionEdit,1,1,1,3);
	m_pDescriptionEdit->setToolTip(__tr2qs_ctx("Visible short description for this action.<br>This string will be displayed to the user so it is a good idea to use $tr() here","editor"));

	l = new QLabel(__tr2qs_ctx("Small icon:","editor"),tab);
	gl->addWidget(l,2,0);
	m_pSmallIconEdit = new QLineEdit(tab);
	gl->addWidget(m_pSmallIconEdit,2,1);
	m_pSmallIconButton = new QToolButton(tab);
	m_pSmallIconButton->setMinimumSize(QSize(20,20));
	connect(m_pSmallIconButton,SIGNAL(clicked()),this,SLOT(chooseSmallIcon()));
	gl->addWidget(m_pSmallIconButton,2,2);
	QString s= __tr2qs_ctx("The small icon associated to this action.<br>" \
		"It will appear at least in the popup menus when this action is inserted.<br>" \
		"It has to be 16x16 pixels.","editor");
	m_pSmallIconEdit->setToolTip(s);
	m_pSmallIconButton->setToolTip(s);

	l = new QLabel(__tr2qs_ctx("Big icon:","editor"),tab);
	gl->addWidget(l,3,0);
	m_pBigIconEdit = new QLineEdit(tab);
	gl->addWidget(m_pBigIconEdit,3,1);
	m_pBigIconButton = new QToolButton(tab);
	m_pBigIconButton->setMinimumSize(QSize(48,48));
	m_pBigIconButton->setIconSize(QSize(32,32));
	connect(m_pBigIconButton,SIGNAL(clicked()),this,SLOT(chooseBigIcon()));
	gl->addWidget(m_pBigIconButton,3,2,2,2);
	s = __tr2qs_ctx("The big icon associated to this action.<br>" \
		"It will appear at least in the toolbar buttons when this action is inserted.<br>" \
		"It has to be 32x32 pixels.","editor");
	m_pBigIconEdit->setToolTip(s);
	m_pBigIconButton->setToolTip(s);

	l = new QLabel(__tr2qs_ctx("Key sequence:","editor"),tab);
	gl->addWidget(l,4,0,2,1);
	m_pKeySequenceEdit = new QLineEdit(tab);
	gl->addWidget(m_pKeySequenceEdit,4,1,2,1);
	m_pKeySequenceEdit->setToolTip(__tr2qs_ctx("Optional keyboard sequence that will activate this action.<br>" \
		"The sequence has to be expressed as a string of up to four key codes separated by commas " \
		"eventually combined with the modifiers \"Ctrl\",\"Shift\",\"Alt\" and \"Meta\".<br>" \
		"Examples of such sequences are \"Ctrl+X\", \"Ctrl+Alt+Z\", \"Ctrl+X,Ctrl+C\" ...","editor"));

	l = new QLabel(tab);
	gl->addWidget(l,6,0,1,4);

	gl->setColumnStretch(1,1);
	gl->setRowStretch(6,1);

	tw->addTab(tab,__tr2qs_ctx("Properties","editor"));

	// flags tab
	tab = new QWidget(tw);
	gl = new QGridLayout(tab);


	m_pNeedsContextCheck = new QCheckBox(__tr2qs_ctx("Needs IRC context","editor"),tab);
	connect(m_pNeedsContextCheck,SIGNAL(toggled(bool)),this,SLOT(needsContextCheckToggled(bool)));
	m_pNeedsContextCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window belongs to an IRC context","editor"));
	gl->addWidget(m_pNeedsContextCheck,0,0,1,4);


	l = new QLabel(tab);
	l->setMinimumWidth(40);
	gl->addWidget(l,1,0);

	m_pNeedsConnectionCheck = new QCheckBox(__tr2qs_ctx("Needs IRC connection","editor"),tab);
	connect(m_pNeedsConnectionCheck,SIGNAL(toggled(bool)),this,SLOT(needsConnectionCheckToggled(bool)));
	m_pNeedsConnectionCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window has an active IRC connection","editor"));
	gl->addWidget(m_pNeedsConnectionCheck,1,1,1,3);


	l = new QLabel(tab);
	l->setMinimumWidth(40);
	gl->addWidget(l,2,1);

	m_pEnableAtLoginCheck = new QCheckBox(__tr2qs_ctx("Enable at login","editor"),tab);
	m_pEnableAtLoginCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled also during " \
		"the login operations (so when the logical IRC connection hasn't been established yet)","editor"));
	gl->addWidget(m_pEnableAtLoginCheck,2,2,1,2);

	m_pSpecificWindowsCheck = new QCheckBox(__tr2qs_ctx("Enable only in specified windows","editor"),tab);
	connect(m_pSpecificWindowsCheck,SIGNAL(toggled(bool)),this,SLOT(specificWindowsCheckToggled(bool)));
	m_pSpecificWindowsCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window is of a specified type","editor"));
	gl->addWidget(m_pSpecificWindowsCheck,3,0,1,4);


	m_pWindowConsoleCheck = new QCheckBox(__tr2qs_ctx("Enable in console windows","editor"),tab);
	m_pWindowConsoleCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window is a console","editor"));
	connect(m_pWindowConsoleCheck,SIGNAL(toggled(bool)),this,SLOT(channelQueryOrConsoleWindowCheckToggled(bool)));
	gl->addWidget(m_pWindowConsoleCheck,4,1,1,3);

	m_pConsoleOnlyIfUsersSelectedCheck = new QCheckBox(__tr2qs_ctx("Only if there are selected users","editor"),tab);
	m_pConsoleOnlyIfUsersSelectedCheck->setToolTip(__tr2qs_ctx("This will enable the action only if there are " \
		"selected users in the active window","editor"));
	gl->addWidget(m_pConsoleOnlyIfUsersSelectedCheck,5,2,1,2);

	m_pWindowChannelCheck = new QCheckBox(__tr2qs_ctx("Enable in channel windows","editor"),tab);
	m_pWindowChannelCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window is a channel","editor"));
	connect(m_pWindowChannelCheck,SIGNAL(toggled(bool)),this,SLOT(channelQueryOrConsoleWindowCheckToggled(bool)));
	gl->addWidget(m_pWindowChannelCheck,6,1,1,3);

	m_pChannelOnlyIfUsersSelectedCheck = new QCheckBox(__tr2qs_ctx("Only if there are selected users","editor"),tab);
	m_pChannelOnlyIfUsersSelectedCheck->setToolTip(__tr2qs_ctx("This will enable the action only if there are " \
		"selected users in the active window","editor"));
	gl->addWidget(m_pChannelOnlyIfUsersSelectedCheck,7,2,1,2);

	m_pWindowQueryCheck = new QCheckBox(__tr2qs_ctx("Enable in query windows","editor"),tab);
	m_pWindowQueryCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window is a query","editor"));
	connect(m_pWindowQueryCheck,SIGNAL(toggled(bool)),this,SLOT(channelQueryOrConsoleWindowCheckToggled(bool)));
	gl->addWidget(m_pWindowQueryCheck,8,1,1,3);

	m_pQueryOnlyIfUsersSelectedCheck = new QCheckBox(__tr2qs_ctx("Only if there are selected users","editor"),tab);
	m_pQueryOnlyIfUsersSelectedCheck->setToolTip(__tr2qs_ctx("This will enable the action only if there are " \
		"selected users in the active window","editor"));
	gl->addWidget(m_pQueryOnlyIfUsersSelectedCheck,9,2,1,2);

	m_pWindowDccChatCheck = new QCheckBox(__tr2qs_ctx("Enable in DCC chat windows","editor"),tab);
	m_pWindowDccChatCheck->setToolTip(__tr2qs_ctx("Check this option if this action should be enabled only when " \
		"the active window is a DCC chat","editor"));
	gl->addWidget(m_pWindowDccChatCheck,10,1,1,2);

	l = new QLabel(tab);
	gl->addWidget(l,11,0,1,4);
	gl->setColumnStretch(3,1);
	gl->setRowStretch(11,1);

	tw->addTab(tab,__tr2qs_ctx("Flags","editor"));
	tw->setCurrentIndex(0);

	g->setRowStretch(2,1);
	g->setColumnStretch(1,1);

	KviPointerHashTableIterator<QString,KviActionCategory> it(*(KviActionManager::instance()->categories()));
	while(KviActionCategory * ac = it.current())
	{
		m_pCategoryCombo->addItem(ac->visibleName() + " (" + ac->name() + ")");
		++it;
	}
}
Exemplo n.º 30
0
void
QvisPluginWindow::CreateWindowContents()
{
    // Create the tab widget.
    QTabWidget *tabs = new QTabWidget(central);
    
    connect(tabs, SIGNAL(currentChanged(int)),
            this, SLOT(tabSelected(int)));
            
    topLayout->addWidget(tabs,10000);

    //
    // Create the plot page
    //
    pagePlots = new QWidget(central);
    QVBoxLayout *plots_layout= new QVBoxLayout(pagePlots);
    tabs->addTab(pagePlots, tr("Plots"));

    plotView = new QTreeView(pagePlots);
    plotView->setModel(plotDataModel);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    plotView->header()->setResizeMode(0,QHeaderView::ResizeToContents);
    plotView->header()->setResizeMode(1,QHeaderView::ResizeToContents);
#else
    plotView->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
    plotView->header()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
#endif
    plots_layout->addWidget(plotView);

    //
    // Create the operator page
    //
    pageOperators = new QWidget(central);
    QVBoxLayout *ops_layout = new QVBoxLayout(pageOperators);
    tabs->addTab(pageOperators, tr("Operators"));
    operatorView = new QTreeView(pageOperators);
    operatorView->setModel(operatorDataModel);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    operatorView->header()->setResizeMode(0,QHeaderView::ResizeToContents);
    operatorView->header()->setResizeMode(1,QHeaderView::ResizeToContents);
#else
    operatorView->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
    operatorView->header()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
#endif
    ops_layout->addWidget(operatorView);

    QHBoxLayout *opsBLayout = new QHBoxLayout();
    ops_layout->addLayout(opsBLayout);
    opsBLayout->addStretch(5);
    clearOperatorCategoryButton = new QPushButton(
        tr("Clear category for all operators"), pageOperators);
    opsBLayout->addWidget(clearOperatorCategoryButton);
    connect(clearOperatorCategoryButton, SIGNAL(clicked()),
            this, SLOT(clearOperatorCategories()));

    //
    // Create the database page
    //
    pageDatabases = new QWidget(central);
    QHBoxLayout *db_toplayout = new QHBoxLayout(pageDatabases);
    QFrame      *db_lframe = new QFrame(pageDatabases);
    db_toplayout->addWidget(db_lframe);
    QVBoxLayout *db_llayout= new QVBoxLayout(db_lframe);
    
    tabs->addTab(pageDatabases, tr("Databases"));

    listDatabases = new QTreeWidget(pageDatabases);
    listDatabases->setRootIsDecorated(false);

    QStringList dbHeaders;
    dbHeaders << tr("Enabled") << tr("Name") << tr("Options") ;
    listDatabases->setHeaderLabels(dbHeaders);
    listDatabases->headerItem()->setTextAlignment(1, Qt::AlignCenter);
    listDatabases->headerItem()->setTextAlignment(2, Qt::AlignCenter);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    listDatabases->header()->setResizeMode(0,QHeaderView::ResizeToContents);
    listDatabases->header()->setResizeMode(2,QHeaderView::ResizeToContents);
#else
    listDatabases->header()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
    listDatabases->header()->setSectionResizeMode(2,QHeaderView::ResizeToContents);
#endif
    db_llayout->addWidget(listDatabases);

    QFrame *grpBox = new QFrame(pageDatabases);
    QHBoxLayout *grp_layout = new QHBoxLayout(grpBox);
    grp_layout->setContentsMargins(5,5,5,5);

    // Add select all and unselect all buttons.
    selectAllReadersButton = new QPushButton(tr("Enable all"), grpBox);
    connect(selectAllReadersButton, SIGNAL(clicked()),
            this, SLOT(selectAllReadersButtonClicked()));
    grp_layout->addWidget(selectAllReadersButton);

    unSelectAllReadersButton = new QPushButton(tr("Disable all"), grpBox);
    connect(unSelectAllReadersButton, SIGNAL(clicked()),
            this, SLOT(unSelectAllReadersButtonClicked()));
    grp_layout->addWidget(unSelectAllReadersButton);
    db_llayout->addWidget(grpBox);

    QFrame      *db_rframe = new QFrame(pageDatabases);
    db_toplayout->addWidget(db_rframe);
    QVBoxLayout *db_rlayout= new QVBoxLayout(db_rframe);

    databaseOptionsSetButton = new QPushButton(tr("Set default open options"),
                                               pageDatabases);
    connect(databaseOptionsSetButton, SIGNAL(clicked()),
            this, SLOT(databaseOptionsSetButtonClicked()));
    connect(listDatabases, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), 
            this, SLOT(databaseSelectedItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
    
    db_rlayout->addWidget(databaseOptionsSetButton);
    
    dbAddToPreferedButton = new QPushButton(tr("Add to preferred list"),
                                            pageDatabases);
    connect(dbAddToPreferedButton, SIGNAL(clicked()),
            this, SLOT(dbAddToPreferedButtonClicked()));
    db_rlayout->addWidget(dbAddToPreferedButton);

    QGroupBox *preferredGroup = new QGroupBox("Preferred Database Plugins",
                                              pageDatabases);
    db_rlayout->addWidget(preferredGroup);
    QGridLayout *preferredLayout = new QGridLayout(preferredGroup);

    QLabel *preferredHintLabel = new QLabel(
        "This is an ordered list of plugins which take precedence when "
        "opening files.  When they accept the given file name pattern, these "
        "are tried frst.  And when all attempts to guess based on file "
        "name fail, these are tried before giving up.", preferredGroup);
    preferredHintLabel->setWordWrap(true);
    preferredLayout->addWidget(preferredHintLabel, 0,0, 1,3);

    listPreferredDBs = new QListWidget(preferredGroup);
    preferredLayout->addWidget(listPreferredDBs, 1,0, 1,3);
    connect(listPreferredDBs,
            SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), 
            this,
            SLOT(dbPreferredListItemChanged(QListWidgetItem*,QListWidgetItem*)));
    
    dbPreferredUpButton = new QPushButton(tr("Up"), preferredGroup);
    connect(dbPreferredUpButton, SIGNAL(clicked()),
            this, SLOT(dbPreferredUpButtonClicked()));
    preferredLayout->addWidget(dbPreferredUpButton, 2,0);

    dbPreferredDownButton = new QPushButton(tr("Down"), preferredGroup);
    connect(dbPreferredDownButton, SIGNAL(clicked()),
            this, SLOT(dbPreferredDownButtonClicked()));
    preferredLayout->addWidget(dbPreferredDownButton, 2,1);

    dbPreferredRemoveButton = new QPushButton(tr("Remove"), preferredGroup);
    connect(dbPreferredRemoveButton, SIGNAL(clicked()),
            this, SLOT(dbPreferredRemoveButtonClicked()));
    preferredLayout->addWidget(dbPreferredRemoveButton, 2,2);

    // Show the appropriate page based on the activeTab setting.
    tabs->blockSignals(true);
    tabs->setCurrentIndex(activeTab);
    tabs->blockSignals(false);
}