コード例 #1
0
void SUiClient::createMsgWindow(QString ID, QString protoName)
{
	SMsgWnd *messageWindow = new SMsgWnd();
	connect(messageWindow, SIGNAL(debug(QString)), this, SIGNAL(debug(QString)));
	messageWindow->Init(ID, protoName, 0);
	registerUi(messageWindow);
	
	connect(this, SIGNAL(windowCreated()), this, SLOT(showAllWindows()));
	
	Ui::msgTabs msgTabs;
	QWidget *tabWindow = new QWidget();
	msgTabs.setupUi(tabWindow);
	
	QTabWidget *tabs = tabWindow->findChild<QTabWidget *>("tabs");
	if(!tabs)
		emit debug("can't find tabs");
	tabs->clear();
	tabs->addTab(messageWindow->getUi(), "msg");

	emit debug("tabs->count() == " + QString::number(tabs->count()));
	
	emit createWidget(SMsgWndProto, messageWindow->protoWidg, protoName);
	emit createWidget(SMsgWndUserInfo, messageWindow->userWidg, protoName);
//	emit createWidget(SMsgBtns, messageWindow->msgWidg, protoName);

	m_windows.append(tabWindow);
	
//	emit windowCreated();	
}
コード例 #2
0
void ModelObserver::notifyChangeName(const std::string &name)
{
	if(!node->isGroup())
		return;
	//{
		//int i = 0;
		QMap<QWidget *, SimulationTab*> tabs = node->getSimulation()->getTabs();

		QTabWidget* tabWidget = node->getSimulation()->getTabWidget();
		for (int i = 0; i < tabWidget->count(); i++) {
			if ( (DM::Module*) tabs[tabWidget->widget(i)]->getParentGroup() == node->getModule() )
				tabWidget->setTabText(i, QString::fromStdString(name));
		}

		/*foreach(SimulationTab* tab, tabs)
		{
			if(((DM::Module*)tab->getParentGroup()) == node->getModule())
				break;
			else
				i++;
		}
		if(i < tabs.size())
			node->getSimulation()->getTabWidget()->setTabText(i, QString::fromStdString(name));
			*/
	//}
}
コード例 #3
0
int ScriptToolbox::tabCount(QWidget * tab)
{
    QTabWidget *tw = qobject_cast<QTabWidget*>(tab);
    if(tw)
        return tw->count();
    return 0;
}
コード例 #4
0
int QTabWidgetProto::count() const
{
  QTabWidget *item = qscriptvalue_cast<QTabWidget*>(thisObject());
  if (item)
    return item->count();
  return 0;
}
コード例 #5
0
ファイル: MainWindow.cpp プロジェクト: banduladh/levelfour
void GCF::Components::MainWindow::addChildWidget(QWidget* parent, QWidget* child)
{
    if(!parent || !child)
        return;

    if(parent == d->workspace)
    {
        d->workspace->addTab(child, child->windowTitle());
        child->installEventFilter(this);
        child->setAutoFillBackground(true);
        emit workspaceWidgetActivated(d->workspace->currentWidget());
    }
    else
    {
        QList<QDockWidget*> dockWidgets = d->dockWidgetMap.values();
        QDockWidget* dw = qobject_cast<QDockWidget*>(parent);
        if(dw && dockWidgets.contains(dw))
        {
            QTabWidget* tw = qobject_cast<QTabWidget*>(dw->widget());
            tw->addTab(child, child->windowTitle());
            child->setAutoFillBackground(true);
            if(tw->count())
                dw->show();
            else
                dw->hide();
        }
    }
}
コード例 #6
0
void PluginTextEditor::closeFileRequest(QString file)
{
	QTabWidget *tabwidget = IPlatform::getInstance()->getWindowManager()->getWindow()->getTabWidget();
	for(int i = 0; i < tabwidget->count(); i++)
	{
		if(file.compare(tabwidget->tabText(i)) == 0)
		{
			if(tabwidget->tabText(i).compare(QString(tr("Welcome"))) == 0)
			{
				QWidget *widget = tabwidget->widget(i);
				tabwidget->removeTab(i);
				delete widget;
			}
			else
			{
				ProjectManager * projectmanager = IPlatform::getInstance()->getProjectManager();
				if(projectmanager->getProject())
				{
					projectmanager->closeFile(file);
				}
			}
			break;
		}
	}
}
コード例 #7
0
void MainWindow::configurate()
{
    if(_paramDiag->exec()) {
        QTabWidget *qtw = _paramDiag->layerTabWidget;
        for(int i = 0; i<qtw->count(); ++i) {
            LayerParameters * ll = static_cast<LayerParameters*> (qtw->widget(i));
            qDebug("%f", ll->youngDoubleSpinBox->value());
        }
    }
}
コード例 #8
0
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());
    }
}
コード例 #9
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);
}
コード例 #10
0
void PluginTextEditor::closeFile(QString file)
{
	QTabWidget *tabwidget = IPlatform::getInstance()->getWindowManager()->getWindow()->getTabWidget();
	for(int i = 0; i < tabwidget->count(); i++)
	{
		if(file.compare(tabwidget->tabText(i)) == 0)
		{
			QWidget *widget = tabwidget->widget(i);
			tabwidget->removeTab(i);
			delete widget;
		}
	}
}
コード例 #11
0
void TilesetItemBox::clearTilesetGroups()
{
    if(lockTilesetBox) return;

    QTabWidget *cat = ui->TileSetsCategories;
    int i = 0;
    int f = cat->count();
    while(f > i)
    {
        //include custom tab
        if(cat->tabText(i) == "Custom")
        {
            ++i;
            continue;
        }

        QWidget *acCat = cat->widget(i);
        cat->removeTab(i);
        delete acCat;
        f = cat->count();
    }
}
コード例 #12
0
QWidget *TilesetItemBox::findTabWidget(const QString &categoryItem)
{
    #ifdef _DEBUG_
    WriteToLog(QtDebugMsg, "TilesetBox -> find Tab");
    #endif
    QTabWidget *cat = ui->TileSetsCategories;
    for(int i = 0; i < cat->count(); ++i)
    {
        if(cat->tabText(i) == categoryItem)
            return cat->widget(i);
    }
    return 0;
}
コード例 #13
0
void Monofin::configurate()
{
    int nbLayers = _projectFile->getHowManyLayers();
    _paramDiag->setNbLayers(nbLayers);
    for (int i=0; i < nbLayers; ++i) {
        _paramDiag->updateLayerDensity(i, _projectFile->getLayerConfigRho(i));
        _paramDiag->updateLayerPoissonRatio(i, _projectFile->getLayerConfigPoisson(i));
        _paramDiag->updateLayerYoungModulus(i, _projectFile->getLayerConfigYoung(i));
    }
    if(_paramDiag->exec()) {
        QTabWidget *qtw = _paramDiag->layerTabWidget;
        if (qtw->count() > 0) {
            _projectFile->startHistory(Data::MonofinLayerConfig);
            for(int i = 0; i<qtw->count(); ++i) {
                LayerParameters * ll = static_cast<LayerParameters*> (qtw->widget(i));
                _projectFile->setLayerConfigPoisson(i, ll->poissonDoubleSpinBox->value());
                _projectFile->setLayerConfigRho(i, ll->densityDoubleSpinBox->value());
                _projectFile->setLayerConfigYoung(i, ll->youngDoubleSpinBox->value());
            }
            _projectFile->stopHistory(Data::MonofinLayerConfig);
        }
    }
}
コード例 #14
0
ファイル: mainwindow.cpp プロジェクト: GravisZro/ZEdit
CMainWindow::CMainWindow(QWidget* parent)
  : QMainWindow(parent)
{
  setMinimumSize(900, 825);
  QTabWidget* tabs = new QTabWidget();

  CBlockEditorTab* block_editor;

  tabs->addTab(new CMapEditorTab(this), "Map Editor");
  tabs->addTab(block_editor = new CBlockEditorTab(this), "Sprite/Tile Editor");
  //tabs->addTab(new CPaletteEditorTab(this), "Manual Palette Editor");
  //tabs->setCurrentIndex(1);


  setStatusBar(new QStatusBar());
  setCentralWidget(tabs);

  //setCentralWidget(block_editor = new CBlockEditorTab(this));

  connect(block_editor, SIGNAL(statusMessage(QString, int)), statusBar(), SLOT(showMessage(QString, int)));

  m_undo = new QAction(this);
  m_redo = new QAction(this);

  addAction(m_undo);
  addAction(m_redo);

  m_undo->setShortcut(QKeySequence::Undo);
  m_redo->setShortcut(QKeySequence::Redo);

  connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(changedTabs(int)));

  for(int i = 0; i < tabs->count(); ++i)
    GData::getUndoStack(i)->clear();

  changedTabs(tabs->currentIndex()); // init tab


  QMenuBar* menubar = new QMenuBar();
  QMenu* file_menu = menubar->addMenu("&File");
  QAction* save_action = file_menu->addAction("&Save");
  save_action->setEnabled(false);
  setMenuBar(menubar);

  connect(save_action, SIGNAL(triggered()), this, SLOT(saveFile()));
}
コード例 #15
0
ファイル: notepadform.cpp プロジェクト: quinsmpang/Tools
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);
		}
	}
}
コード例 #16
0
void Prefs::changeEvent(QEvent *e) {
    if (e->type() == QEvent::LanguageChange) {
        retranslateUi(this);
        // update the widgets' tabs
        for (int i=0; i<tabWidgetStack->count(); i++) {
            QTabWidget* tabWidget = (QTabWidget*)tabWidgetStack->widget(i);
            for (int j=0; j<tabWidget->count(); j++) {
                QWidget* page = tabWidget->widget(j);
                tabWidget->setTabText(j, page->windowTitle());
            }
        }
        // update the items' text
        for (int i=0; i<listBox->count(); i++) {
            QListWidgetItem *item = listBox->item(i);
            QByteArray group = item->data(Qt::UserRole).toByteArray();
            item->setText(QObject::tr(group.constData()));
        }
    } else {
        QWidget::changeEvent(e);
    }
}
コード例 #17
0
ファイル: ui_qt.cpp プロジェクト: wiktorek140/RetroArch
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;
}
コード例 #18
0
ファイル: ui_qt.cpp プロジェクト: DoctorGoat/RetroArch_LibNX
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;
}
コード例 #19
0
ファイル: cdrv.cpp プロジェクト: weigj/loongide
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;
}
コード例 #20
0
ファイル: guipanel.cpp プロジェクト: cfcohen/openbrf
GuiPanel::GuiPanel(QWidget *parent, IniData &id) :
    QWidget(parent),
    inidata(id),
    ui(new Ui::GuiPanel)
{
  reference = NULL;
  curMaterialFocus = DIFFUSEA;

  //mapMT = mm;
  _selectedIndex = -1;

  ui->setupUi(this);

//  ui->attributeData->tabBar()->setContentsMargins(-4,0,-4,0);
  QTabWidget *tw = ui->attributeData;
  int mar = 0;
  tw->setStyleSheet(QString("QTabBar::tab { width: %1px;padding-top: 1px; padding-bottom: 1px;margin-right: %2px;margin-left: %2px;} ")
                    .arg((tw->size().width()+(2*mar*tw->count())-1)/tw->count()).arg(-mar)
                    );

  ui->wiBodyAxisA->setVisible(false);
  ui->wiBodyAxisB->setVisible(false);
  ui->wiBodyRadius->setVisible(false);
  ui->wiBodyNFaces->setVisible(false);
  ui->wiBodyNVerts->setVisible(false);
  ui->wiBodySigns->setVisible(false);
  ui->wiBodyFlags->setVisible(false);

  ui->bodyData->setVisible(false);
  ui->meshData->setVisible(false);
  ui->textureData->setVisible(false);
  ui->animationData->setVisible(false);
  ui->materialData->setVisible(false);
  ui->skeletonData->setVisible(false);
  ui->shaderData->setVisible(false);
  ui->hitboxEdit->setVisible(false);

  ui->viewRuler->setVisible(false);
  ui->viewFloatingProbe->setVisible(false);
  ui->generalView->setVisible(false);
  ui->vertexData->setVisible(false);


  ui->lvTextAcc->setModel( new TextureAccessModel(this) );
  ui->lvBodyPart->setModel( new BodyPartModel(this) );
  ui->lvBones->setModel( new BodyPartModel(this) );


  //ui->frameNumber->setBackgroundRole(QPalette::Foreground);
  //ui->frameNumberAni->setBackgroundRole(QPalette::Foreground);

  alignY(ui->textureData  ,ui->meshData);
  alignY(ui->materialData  ,ui->meshData);
  alignY(ui->animationData,ui->meshData);
  alignY(ui->skeletonData,ui->meshData);
  alignY(ui->shaderData,  ui->meshData);
  alignY(ui->bodyData,  ui->meshData);

  alignYAfter(ui->hitboxEdit, ui->skeletonData);
  alignY(ui->vertexData,  ui->meshData);
  //alignYAfter(ui->vertexData , ui->meshData );

  QString flagMask(">Hhhhhhhh");
  ui->boxFlags->setInputMask(flagMask);
  ui->boxTextureFlags->setInputMask(flagMask);
  ui->leMatFlags->setInputMask(flagMask);
  ui->leShaderFlags->setInputMask(flagMask);
  ui->leShaderTaFlags->setInputMask(flagMask);
  ui->leBodyFlags->setInputMask(flagMask);
  ui->leShaderRequires->setInputMask(flagMask);

  skel = NULL;

  //ui->leMatR->setInputMask("0.0000");
  //ui->leMatG->setInputMask("0.0000");
  //ui->leMatB->setInputMask("0.0000");
  //ui->leMatCoeff->setInputMask("0000");
  //ui->timeOfFrame->setInputMask("0000");

  textureAccessDup = new QAction("Duplicate",this);
  textureAccessDel = new QAction("Remove",this);
  textureAccessAdd = new QAction("Add",this);

  bodyPartDup = new QAction("Duplicate",this);
  bodyPartDel = new QAction("Remove",this);
  bodyPartAdd = new QAction("Add",this);

  connect(ui->cbSkin, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateVisibility()));
  connect(ui->cbRefani, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateVisibility()));
  connect(ui->cbRuler, SIGNAL(stateChanged(int)), this, SLOT(updateVisibility()));
  connect(ui->cbRefani, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateRefAnimation()));

  connect(ui->rulerSlid, SIGNAL(sliderMoved (int)), this, SLOT(setRulerLenght(int)));
  connect(ui->rulerSpin, SIGNAL(valueChanged(int)), this, SLOT(setRulerLenght(int)));

  connect(ui->lvTextAcc->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(updateShaderTextaccData()));
  connect(ui->lvBodyPart->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(updateBodyPartData()));
  connect(ui->lvBones->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(updateSelectedBone()));


  // skeleton direct editing
  connect(ui->editHbRange, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbLenTop, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbLenBot, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbPosX, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbPosY, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbPosZ, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbRotAlpha, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));
  connect(ui->editHbRotBeta, SIGNAL(actionTriggered(int)),this,SLOT(onEditHitbox(int)));

  QString st = tr(" (keep [shift] pressed to nudge)");
  ui->editHbRange->setStatusTip(ui->editHbRange->statusTip()+st);
  ui->editHbLenTop->setStatusTip(ui->editHbLenTop->statusTip()+st);
  ui->editHbLenBot->setStatusTip(ui->editHbLenBot->statusTip()+st);
  ui->editHbPosX->setStatusTip(ui->editHbPosX->statusTip()+st);
  ui->editHbPosY->setStatusTip(ui->editHbPosY->statusTip()+st);
  ui->editHbPosZ->setStatusTip(ui->editHbPosZ->statusTip()+st);
  ui->editHbRotAlpha->setStatusTip(ui->editHbRotAlpha->statusTip()+st);
  ui->editHbRotBeta->setStatusTip(ui->editHbRotBeta->statusTip()+st);

  connect(ui->editHbActive, SIGNAL(stateChanged(int)),this,SLOT(setHbEditVisible(int)));

  connect(ui->floatingProbeX,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos()));
  connect(ui->floatingProbeY,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos()));
  connect(ui->floatingProbeZ,SIGNAL(valueChanged(double)),this,SLOT(onEditFloatingProbePos()));

  // add a shortcut to hide/show skin
  quickToggleHideSkinAct = new QAction(this);
  quickToggleHideSkinAct->setShortcut(QKeySequence("space"));
  //quickToggleHideSkinAct->setShortcutContext(Qt::ApplicationShortcut);
  connect(quickToggleHideSkinAct, SIGNAL(triggered()),this,SLOT(quickToggleHideSkin()));
  ui->cbSkin->addAction(quickToggleHideSkinAct);

  connect(ui->cbFloatingProbe,SIGNAL(toggled(bool)),parent,SLOT(activateFloatingProbe(bool)));
  connect(ui->cbRuler,SIGNAL(toggled(bool)),parent,SLOT(activateRuler(bool)));

}
コード例 #21
0
ファイル: QtlTabWidget.cpp プロジェクト: Wushaowei001/NAF
int TabWidget::count( lua_State * L ) // const int
{
	QTabWidget* obj = ObjectHelper<QTabWidget>::check( L, 1 );
	Util::push( L, obj->count() );
	return 1;
}
コード例 #22
-1
ファイル: MainWindow.cpp プロジェクト: banduladh/levelfour
void GCF::Components::MainWindow::removeChildWidget(QWidget* parent, QWidget* child)
{
    if(!parent || !child)
        return;

    if(parent == d->workspace)
    {
        d->workspace->removeTab(d->workspace->indexOf(child));
        child->removeEventFilter(this);
    }
    else
    {
        QList<QDockWidget*> dockWidgets = d->dockWidgetMap.values();
        QDockWidget* dw = qobject_cast<QDockWidget*>(parent);
        if(dw && dockWidgets.contains(dw))
        {
            QTabWidget* tw = qobject_cast<QTabWidget*>(dw->widget());
            tw->removeTab(tw->indexOf(child));
            if(tw->count())
                dw->show();
            else
                dw->hide();
        }
    }
}