void MainWindow::createStackedWidget() { // List of all items in the left navigation bar QListWidget* lw = new QListWidget(this); lw->setFixedWidth(100); lw->setSelectionMode(QAbstractItemView::SingleSelection); QListWidgetItem* connectionItem = new QListWidgetItem; connectionItem->setText("Connexion"); lw->insertItem(0,connectionItem); QListWidgetItem* curriculumItem = new QListWidgetItem; curriculumItem->setText("Mon parcours"); lw->insertItem(1,curriculumItem); QListWidgetItem* expectationsItem = new QListWidgetItem; expectationsItem->setText("Prévisions"); lw->insertItem(2,expectationsItem); QListWidgetItem* catalogItem = new QListWidgetItem; catalogItem->setText("Catalogue Uvs"); lw->insertItem(3,catalogItem); QListWidgetItem* adminItem = new QListWidgetItem; adminItem->setText("Gestion Uvs"); lw->insertItem(4,adminItem); // Create the pages admin_ = new Admin; catalog_ = new Catalog; curriculum_ = new Curriculum; expectations_ = new Expectations; connection_ = new Connection; // Link the pages with the vertical navigation bar navigationStackedWidget_ = new QStackedWidget; navigationStackedWidget_->addWidget(connection_); navigationStackedWidget_->addWidget(curriculum_); navigationStackedWidget_->addWidget(expectations_); navigationStackedWidget_->addWidget(catalog_); navigationStackedWidget_->addWidget(admin_); QHBoxLayout* mainLayout = new QHBoxLayout; mainLayout->addWidget(lw); mainLayout->addWidget(navigationStackedWidget_); QWidget* cw = new QWidget; cw->setLayout(mainLayout); setCentralWidget(cw); curriculum_->setEnabled(false); expectations_->setEnabled(false); QObject::connect(lw,SIGNAL(currentRowChanged(int)),this,SLOT(setTag(int))); QObject::connect(connection_,SIGNAL(connected()),expectations_,SLOT(updateExpComboBox())); QObject::connect(connection_,SIGNAL(connected()),curriculum_,SLOT(generationView())); QObject::connect(connection_,SIGNAL(connected()),this,SLOT(afterConnection())); }
AboutPlugins::AboutPlugins( Config *_config, QWidget* parent, Qt::WFlags f ) : KDialog( parent, f ), config( _config ), currentPlugin( 0 ) { setCaption( i18n("About plugins") ); setWindowIcon( KIcon("preferences-plugin") ); setButtons( KDialog::Close ); setButtonFocus( KDialog::Close ); QWidget *widget = new QWidget( this ); setMainWidget( widget ); QHBoxLayout *box = new QHBoxLayout( widget ); QVBoxLayout *pluginListBox = new QVBoxLayout( widget ); box->addLayout( pluginListBox ); QLabel *installedPlugins = new QLabel( i18n("Installed plugins:"), this ); pluginListBox->addWidget( installedPlugins ); QListWidget *pluginsList = new QListWidget( this ); pluginListBox->addWidget( pluginsList ); connect( pluginsList, SIGNAL(currentTextChanged(const QString&)), this, SLOT(currentPluginChanged(const QString&)) ); QStringList pluginNames; QList<CodecPlugin*> codecPlugins = config->pluginLoader()->getAllCodecPlugins(); for( int i=0; i<codecPlugins.count(); i++ ) { pluginNames += codecPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginNames.clear(); QList<FilterPlugin*> filterPlugins = config->pluginLoader()->getAllFilterPlugins(); for( int i=0; i<filterPlugins.count(); i++ ) { pluginNames += filterPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginNames.clear(); QList<ReplayGainPlugin*> replaygainPlugins = config->pluginLoader()->getAllReplayGainPlugins(); for( int i=0; i<replaygainPlugins.count(); i++ ) { pluginNames += replaygainPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginNames.clear(); QList<RipperPlugin*> ripperPlugins = config->pluginLoader()->getAllRipperPlugins(); for( int i=0; i<ripperPlugins.count(); i++ ) { pluginNames += ripperPlugins.at(i)->name(); } pluginNames.sort(); pluginsList->addItems( pluginNames ); pluginsList->setFixedWidth( 180 ); box->addSpacing( 10 ); QVBoxLayout *pluginInfoBox = new QVBoxLayout( widget ); box->addLayout( pluginInfoBox ); aboutPluginLabel = new QLabel( this ); aboutPluginLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); aboutPluginLabel->setWordWrap( true ); aboutPluginLabel->setTextFormat( Qt::RichText ); pluginInfoBox->addWidget( aboutPluginLabel ); connect( aboutPluginLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showProblemInfo(const QString&)) ); pluginInfoBox->addStretch(); QHBoxLayout *configurePluginBox = new QHBoxLayout( widget ); pluginInfoBox->addLayout( configurePluginBox ); configurePlugin = new KPushButton( KIcon("configure"), "", widget ); configurePlugin->hide(); configurePluginBox->addWidget( configurePlugin ); configurePluginBox->addStretch(); connect( configurePlugin, SIGNAL(clicked()), this, SLOT(configurePluginClicked()) ); pluginsList->setCurrentRow(0); QListWidgetItem *currentItem = pluginsList->currentItem(); if( currentItem ) { currentPluginChanged( currentItem->text() ); } setInitialSize( QSize(500,300) ); KSharedConfig::Ptr conf = KGlobal::config(); KConfigGroup group = conf->group( "AboutPlugins" ); restoreDialogSize( group ); }
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) : QDialog(parent), _ui(new Ui::SettingsDialog) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); _ui->setupUi(this); setObjectName("Settings"); // required as group for saveGeometry call setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI())); _accountSettings = new AccountSettings(this); addAccount(tr("Account"), _accountSettings); QIcon protocolIcon(QLatin1String(":/mirall/resources/activity.png")); QListWidgetItem *protocol= new QListWidgetItem(protocolIcon, tr("Activity"), _ui->labelWidget); protocol->setSizeHint(QSize(0, 32)); _ui->labelWidget->addItem(protocol); _protocolWidget = new ProtocolWidget; _protocolIdx = _ui->stack->addWidget(_protocolWidget); QIcon generalIcon(QLatin1String(":/mirall/resources/settings.png")); QListWidgetItem *general = new QListWidgetItem(generalIcon, tr("General"), _ui->labelWidget); general->setSizeHint(QSize(0, 32)); _ui->labelWidget->addItem(general); GeneralSettings *generalSettings = new GeneralSettings; _ui->stack->addWidget(generalSettings); QIcon networkIcon(QLatin1String(":/mirall/resources/network.png")); QListWidgetItem *network = new QListWidgetItem(networkIcon, tr("Network"), _ui->labelWidget); network->setSizeHint(QSize(0, 32)); _ui->labelWidget->addItem(network); NetworkSettings *networkSettings = new NetworkSettings; _ui->stack->addWidget(networkSettings); connect( _accountSettings, SIGNAL(folderChanged()), gui, SLOT(slotFoldersChanged())); connect( _accountSettings, SIGNAL(accountIconChanged(QIcon)), SLOT(slotUpdateAccountIcon(QIcon))); connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)), gui, SLOT(slotFolderOpenAction(QString))); connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)), _accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) ); _ui->labelWidget->setCurrentRow(_ui->labelWidget->row(_accountItem)); connect(_ui->labelWidget, SIGNAL(currentRowChanged(int)), _ui->stack, SLOT(setCurrentIndex(int))); QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close); connect(closeButton, SIGNAL(clicked()), SLOT(accept())); QAction *showLogWindow = new QAction(this); showLogWindow->setShortcut(QKeySequence("F12")); connect(showLogWindow, SIGNAL(triggered()), gui, SLOT(slotToggleLogBrowser())); addAction(showLogWindow); int iconSize = 32; QListWidget *listWidget = _ui->labelWidget; int spacing = 20; // reverse at least ~8 characters int effectiveWidth = fontMetrics().averageCharWidth() * 8 + iconSize + spacing; // less than ~16 characters, elide otherwise int maxWidth = fontMetrics().averageCharWidth() * 16 + iconSize + spacing; for (int i = 0; i < listWidget->count(); i++) { QListWidgetItem *item = listWidget->item(i); QFontMetrics fm(item->font()); int curWidth = fm.width(item->text()) + iconSize + spacing; effectiveWidth = qMax(curWidth, effectiveWidth); if (curWidth > maxWidth) item->setToolTip(item->text()); } effectiveWidth = qMin(effectiveWidth, maxWidth); listWidget->setFixedWidth(effectiveWidth); MirallConfigFile cfg; cfg.restoreGeometry(this); }
QWidget *ConfigDialog::centerWidget() { /* m_pagesTabWidget = new QTabWidget; for (int i = 0; i < m_pageWidgets.size(); ++i) m_pagesTabWidget->addTab(m_pageWidgets.at(i), m_pageTitles.at(i)); return m_pagesTabWidget; */ // create list QListWidget *pagesListWidget = new QListWidget; pagesListWidget->setViewMode(QListView::IconMode); pagesListWidget->setMovement(QListView::Static); pagesListWidget->setFlow(QListView::TopToBottom); pagesListWidget->setWordWrap(true); pagesListWidget->setUniformItemSizes(true); pagesListWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); // add items to list QFontMetrics fm(qApp->font()); int iconWidth = 0; for (int i = 0; i < m_pagesListWidgetItems.size(); ++i) iconWidth = qMax(iconWidth, fm.boundingRect(0, 0, 0, 0, Qt::AlignCenter, m_pagesListWidgetItems.at(i)->text()).width()); iconWidth += 20; const int iconHeight = fm.height() + 42; for (int i = 0; i < m_pagesListWidgetItems.size(); ++i) { m_pagesListWidgetItems.at(i)->setSizeHint(QSize(iconWidth, iconHeight)); pagesListWidget->addItem(m_pagesListWidgetItems.at(i)); } pagesListWidget->setFixedWidth(m_pagesListWidgetItems.at(0)->sizeHint().width() + 6); // create title QFrame *titleFrame = new QFrame(this); // titleFrame->setAutoFillBackground(true); // titleFrame->setFrameShape(QFrame::StyledPanel); titleFrame->setFrameShape(QFrame::Box); // titleFrame->setFrameShadow(QFrame::Plain); // titleFrame->setBackgroundRole(QPalette::Base); m_pagesTitleLabel = new QLabel(titleFrame); m_pagesTitleLabel->setStyleSheet("QLabel { font-weight: bold; }"); QGridLayout *titleLayout = new QGridLayout(titleFrame); titleLayout->setColumnStretch(0, 1); titleLayout->setMargin(6); titleLayout->addWidget(m_pagesTitleLabel); // add pages QStackedWidget *pagesStackedWidget = new QStackedWidget; for (int i = 0; i < m_pageWidgets.size(); ++i) pagesStackedWidget->addWidget(m_pageWidgets.at(i)); connect(pagesListWidget, SIGNAL(currentRowChanged(int)), pagesStackedWidget, SLOT(setCurrentIndex(int))); connect(pagesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setCurrentPage(int))); pagesListWidget->setCurrentRow(0); QWidget *mainWidget = new QWidget; QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(pagesListWidget, 0, 0, 2, 1); mainLayout->addWidget(titleFrame, 0, 1); mainLayout->addWidget(pagesStackedWidget, 1, 1); mainWidget->setLayout(mainLayout); return mainWidget; }