void IdDialog::processSettings(bool load) { QHeaderView *header = ui->treeWidget_IdList->header(); Settings->beginGroup("IdDialog"); if (load) { // load settings // filterColumn ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt()); // state of thread tree header->restoreState(Settings->value("IdList").toByteArray()); // state of splitter ui->splitter->restoreState(Settings->value("splitter").toByteArray()); } else { // save settings // filterColumn Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); // state of thread tree Settings->setValue("IdList", header->saveState()); // state of splitter Settings->setValue("splitter", ui->splitter->saveState()); } Settings->endGroup(); }
void CFileListView::restoreHeaderState() { QHeaderView * headerView = header(); assert_and_return_r(headerView, ); if (!_headerGeometry.isEmpty()) headerView->restoreGeometry(_headerGeometry); if (!_headerState.isEmpty()) headerView->restoreState(_headerState); }
void ChunkDownloadView::loadState(KSharedConfigPtr cfg) { KConfigGroup g = cfg->group("ChunkDownloadView"); QByteArray s = QByteArray::fromBase64(g.readEntry("state", QByteArray())); if (!s.isNull()) { QHeaderView* v = m_chunk_view->header(); v->restoreState(s); m_chunk_view->sortByColumn(v->sortIndicatorSection(), v->sortIndicatorOrder()); model->sort(v->sortIndicatorSection(), v->sortIndicatorOrder()); } }
UserBrokerTransactionsWidget::UserBrokerTransactionsWidget(QTabFramework& tabFramework, QSettings& settings, Entity::Manager& entityManager, DataService& dataService) : QWidget(&tabFramework), tabFramework(tabFramework), entityManager(entityManager), dataService(dataService), transactionsModel(entityManager) { entityManager.registerListener<EConnection>(*this); setWindowTitle(tr("Transactions")); QToolBar* toolBar = new QToolBar(this); toolBar->setStyleSheet("QToolBar { border: 0px }"); toolBar->setIconSize(QSize(16, 16)); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); refreshAction = toolBar->addAction(QIcon(":/Icons/arrow_refresh.png"), tr("&Refresh")); refreshAction->setEnabled(false); refreshAction->setShortcut(QKeySequence(QKeySequence::Refresh)); connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh())); transactionView = new QTreeView(this); transactionView->setUniformRowHeights(true); proxyModel = new UserBrokerTransactionsSortProxyModel(this); proxyModel->setSourceModel(&transactionsModel); proxyModel->setDynamicSortFilter(true); transactionView->setModel(proxyModel); transactionView->setSortingEnabled(true); transactionView->setRootIsDecorated(false); transactionView->setAlternatingRowColors(true); //transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); layout->addWidget(toolBar); layout->addWidget(transactionView); setLayout(layout); QHeaderView* headerView = transactionView->header(); headerView->resizeSection(0, 50); headerView->resizeSection(1, 110); headerView->resizeSection(2, 85); headerView->resizeSection(3, 100); headerView->resizeSection(4, 85); headerView->resizeSection(5, 75); headerView->resizeSection(6, 85); transactionView->sortByColumn(1); settings.beginGroup("Transactions"); headerView->restoreState(settings.value("HeaderState").toByteArray()); settings.endGroup(); headerView->setStretchLastSection(false); headerView->setResizeMode(0, QHeaderView::Stretch); }
void ScanGallery::restoreHeaderState(const QString &key) { const KConfigGroup grp = KGlobal::config()->group(COLUMN_STATES_GROUP); kDebug() << "from" << key; QString state = grp.readEntry(key, ""); if (!state.isEmpty()) { QHeaderView *hdr = header(); // same workaround as needed in Akregator (even with Qt 4.6), // see r918196 and r1001242 to kdepim/akregator/src/articlelistview.cpp hdr->resizeSection(hdr->logicalIndex(hdr->count()-1), 1); hdr->restoreState(QByteArray::fromBase64(state.toAscii())); } }
void MainWindow::restoreWindowState(bool bStartHidden) { QHeaderView* hdr = treeTransfers->header(); QVariant state = g_settings->value("state/mainheaders"); if(state.isNull()) hdr->resizeSection(0, 300); else hdr->restoreState(state.toByteArray()); state = g_settings->value("state/mainsplitter"); if(state.isNull()) splitterQueues->setSizes(QList<int>() << 80 << 600); else splitterQueues->restoreState(state.toByteArray()); state = g_settings->value("state/statssplitter"); if(!state.isNull()) splitterStats->restoreState(state.toByteArray()); connect(hdr, SIGNAL(sectionResized(int,int,int)), this, SLOT(saveWindowState())); connect(splitterQueues, SIGNAL(splitterMoved(int,int)), this, SLOT(saveWindowState())); QPoint pos = g_settings->value("state/mainwindow_pos").toPoint(); QSize size = g_settings->value("state/mainwindow_size").toSize(); if(size.isEmpty()) { qDebug() << "Maximizing the main window"; if(!bStartHidden) showMaximized(); } else { QWidget::move(pos); resize(size); if(!bStartHidden) show(); } if(bStartHidden) actionDisplay->setChecked(false); resizeEvent(0); }
void KFLogTreeWidget::loadConfig() { if( confName.isEmpty() ) { // Configuration name is empty, do nothing. return; } QHeaderView* headerView = header(); if( headerView->count() == 0 ) { return; } QString path = "/KFLogTreeWidget/" + confName + "-Header"; bool ok = headerView->restoreState( _settings.value( path ).toByteArray() ); if( ! ok ) { qWarning() << "KFLogTreeWidget::loadConfig(): Could not restore header of" << confName; } }
bool ListingTable::restoreState(const QByteArray& state) { QHeaderView* header = horizontalHeader(); return header->restoreState(state); }
UserSessionsWidget::UserSessionsWidget(QTabFramework& tabFramework, QSettings& settings, Entity::Manager& entityManager, DataService& dataService) : QWidget(&tabFramework), tabFramework(tabFramework), entityManager(entityManager), dataService(dataService), sessionsModel(entityManager), /*ordersModel(entityManager), transactionModel(entityManager), */selectedSessionId(0) { entityManager.registerListener<EConnection>(*this); setWindowTitle(tr("Bot Sessions")); QToolBar* toolBar = new QToolBar(this); toolBar->setStyleSheet("QToolBar { border: 0px }"); toolBar->setIconSize(QSize(16, 16)); toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addAction = toolBar->addAction(QIcon(":/Icons/user_gray_add.png"), tr("&Add")); addAction->setEnabled(false); connect(addAction, SIGNAL(triggered()), this, SLOT(addBot())); //optimizeAction = toolBar->addAction(QIcon(":/Icons/chart_curve.png"), tr("&Optimize")); //optimizeAction->setEnabled(false); //connect(optimizeAction, SIGNAL(triggered()), this, SLOT(optimize())); simulateAction = toolBar->addAction(QIcon(":/Icons/user_gray_go_gray.png"), tr("&Simulate")); simulateAction->setEnabled(false); connect(simulateAction, SIGNAL(triggered()), this, SLOT(simulate())); activateAction = toolBar->addAction(QIcon(":/Icons/user_gray_go.png"), tr("&Activate")); activateAction->setEnabled(false); connect(activateAction, SIGNAL(triggered()), this, SLOT(activate())); cancelAction = toolBar->addAction(QIcon(":/Icons/cancel2.png"), tr("&Cancel")); cancelAction->setEnabled(false); connect(cancelAction, SIGNAL(triggered()), this, SLOT(cancelBot())); sessionView = new QTreeView(this); sessionView->setUniformRowHeights(true); proxyModel = new QSortFilterProxyModel(this); proxyModel->setDynamicSortFilter(true); proxyModel->setSourceModel(&sessionsModel); sessionView->setModel(proxyModel); sessionView->setSortingEnabled(true); sessionView->setRootIsDecorated(false); sessionView->setAlternatingRowColors(true); connect(sessionView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(sessionSelectionChanged())); connect(&sessionsModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(sessionDataChanged(const QModelIndex&, const QModelIndex&))); connect(&sessionsModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(sessionDataRemoved(const QModelIndex&, int, int))); connect(&sessionsModel, SIGNAL(modelReset()), this, SLOT(sessionDataReset())); connect(&sessionsModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(sessionDataAdded(const QModelIndex&, int, int))); QVBoxLayout* layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); layout->addWidget(toolBar); layout->addWidget(sessionView); setLayout(layout); QHeaderView* headerView = sessionView->header(); //headerView->resizeSection(0, 300); settings.beginGroup("BotSessions"); headerView->restoreState(settings.value("HeaderState").toByteArray()); selectedSessionId = settings.value("SelectedSessionId").toUInt(); settings.endGroup(); headerView->setStretchLastSection(false); headerView->setResizeMode(0, QHeaderView::Stretch); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_transferMenu(new QMenu(tr("Download"), this)), m_packageMenu(new QMenu(tr("Package"), this)), m_addUrlsAction(new QAction(QIcon::fromTheme("general_add"), tr("Add URLs"), this)), m_importUrlsAction(new QAction(QIcon::fromTheme("general_toolbar_folder"), tr("Import URLs"), this)), m_retrieveUrlsAction(new QAction(QIcon::fromTheme("general_search"), tr("Retrieve URLs"), this)), m_clipboardUrlsAction(new QAction(QIcon::fromTheme("general_share"), tr("Clipboard URLs"), this)), m_queueAction(new QAction(QIcon("/etc/hildon/theme/mediaplayer/Play.png"), tr("Start all DLs"), this)), m_pauseAction(new QAction(QIcon("/etc/hildon/theme/mediaplayer/Pause.png"), tr("Pause all DLs"), this)), m_propertiesAction(new QAction(QIcon::fromTheme("general_information"), tr("Properties"), this)), m_transferQueueAction(new QAction(tr("Start"), this)), m_transferPauseAction(new QAction(tr("Pause"), this)), m_transferCancelAction(new QAction(tr("Remove"), this)), m_transferCancelDeleteAction(new QAction(tr("Remove and delete files"), this)), m_packageQueueAction(new QAction(tr("Start"), this)), m_packagePauseAction(new QAction(tr("Pause"), this)), m_packageCancelAction(new QAction(tr("Remove"), this)), m_packageCancelDeleteAction(new QAction(tr("Remove and delete files"), this)), m_settingsAction(new QAction(tr("Settings"), this)), m_pluginsAction(new QAction(tr("Load plugins"), this)), m_aboutAction(new QAction(tr("About"), this)), m_concurrentAction(new ValueSelectorAction(tr("Maximum concurrent DLs"), this)), m_nextAction(new ValueSelectorAction(tr("After current DLs"), this)), m_view(new QTreeView(this)), m_toolBar(new QToolBar(this)), m_activeLabel(new QLabel(QString("%1DLs").arg(TransferModel::instance()->activeTransfers()), this)), m_speedLabel(new QLabel(Utils::formatBytes(TransferModel::instance()->totalSpeed()) + "/s", this)) { setWindowTitle("QDL"); setCentralWidget(m_view); addToolBar(Qt::BottomToolBarArea, m_toolBar); menuBar()->addAction(m_concurrentAction); menuBar()->addAction(m_nextAction); menuBar()->addAction(m_queueAction); menuBar()->addAction(m_pauseAction); menuBar()->addAction(m_settingsAction); menuBar()->addAction(m_pluginsAction); menuBar()->addAction(m_aboutAction); m_addUrlsAction->setShortcut(tr("Ctrl+N")); m_importUrlsAction->setShortcut(tr("Ctrl+O")); m_retrieveUrlsAction->setShortcut(tr("Ctrl+F")); m_propertiesAction->setShortcut(tr("Ctrl+I")); m_propertiesAction->setEnabled(false); m_clipboardUrlsAction->setShortcut(tr("Ctrl+U")); m_pluginsAction->setShortcut(tr("Ctrl+L")); m_transferMenu->addAction(m_transferQueueAction); m_transferMenu->addAction(m_transferPauseAction); m_transferMenu->addAction(m_transferCancelAction); m_transferMenu->addAction(m_transferCancelDeleteAction); m_packageMenu->addAction(m_packageQueueAction); m_packageMenu->addAction(m_packagePauseAction); m_packageMenu->addAction(m_packageCancelAction); m_packageMenu->addAction(m_packageCancelDeleteAction); m_concurrentAction->setModel(new ConcurrentTransfersModel(m_concurrentAction)); m_concurrentAction->setValue(Settings::maximumConcurrentTransfers()); m_nextAction->setModel(new ActionModel(m_nextAction)); m_nextAction->setValue(Settings::nextAction()); QLabel *speedIcon = new QLabel(m_toolBar); speedIcon->setPixmap(QIcon::fromTheme("general_received").pixmap(m_toolBar->iconSize())); QWidget *spacer1 = new QWidget(m_toolBar); spacer1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QWidget *spacer2 = new QWidget(m_toolBar); spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_activeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_speedLabel->setMinimumWidth(m_speedLabel->fontMetrics().width("9999.99MB/s")); m_speedLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_toolBar->setAllowedAreas(Qt::BottomToolBarArea); m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); m_toolBar->setMovable(false); m_toolBar->addAction(m_addUrlsAction); m_toolBar->addAction(m_importUrlsAction); m_toolBar->addAction(m_retrieveUrlsAction); m_toolBar->addAction(m_clipboardUrlsAction); m_toolBar->addAction(m_propertiesAction); m_toolBar->addWidget(spacer1); m_toolBar->addWidget(m_activeLabel); m_toolBar->addWidget(spacer2); m_toolBar->addWidget(m_speedLabel); m_toolBar->addWidget(speedIcon); m_view->setModel(TransferModel::instance()); m_view->setSelectionBehavior(QTreeView::SelectRows); m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_view->setEditTriggers(QTreeView::NoEditTriggers); m_view->setExpandsOnDoubleClick(true); m_view->setItemsExpandable(true); m_view->setUniformRowHeights(true); m_view->setAllColumnsShowFocus(true); QHeaderView *header = m_view->header(); if (!header->restoreState(Settings::transferViewHeaderState())) { const QFontMetrics fm = header->fontMetrics(); header->resizeSection(0, 200); header->resizeSection(2, fm.width("999.99MB of 999.99MB (99.99%)")); header->resizeSection(3, fm.width("999.99KB/s")); header->hideSection(1); // Hide priority column } connect(Settings::instance(), SIGNAL(maximumConcurrentTransfersChanged(int)), this, SLOT(onMaximumConcurrentTransfersChanged(int))); connect(Settings::instance(), SIGNAL(nextActionChanged(int)), this, SLOT(onNextActionChanged(int))); connect(TransferModel::instance(), SIGNAL(captchaRequest(TransferItem*)), this, SLOT(showCaptchaDialog(TransferItem*))); connect(TransferModel::instance(), SIGNAL(settingsRequest(TransferItem*)), this, SLOT(showPluginSettingsDialog(TransferItem*))); connect(TransferModel::instance(), SIGNAL(activeTransfersChanged(int)), this, SLOT(onActiveTransfersChanged(int))); connect(TransferModel::instance(), SIGNAL(totalSpeedChanged(int)), this, SLOT(onTotalSpeedChanged(int))); connect(m_transferMenu, SIGNAL(aboutToShow()), this, SLOT(setTransferMenuActions())); connect(m_packageMenu, SIGNAL(aboutToShow()), this, SLOT(setPackageMenuActions())); connect(m_addUrlsAction, SIGNAL(triggered()), this, SLOT(showAddUrlsDialog())); connect(m_importUrlsAction, SIGNAL(triggered()), this, SLOT(showImportUrlsDialog())); connect(m_retrieveUrlsAction, SIGNAL(triggered()), this, SLOT(showRetrieveUrlsDialog())); connect(m_clipboardUrlsAction, SIGNAL(triggered()), this, SLOT(showClipboardUrlsDialog())); connect(m_queueAction, SIGNAL(triggered()), TransferModel::instance(), SLOT(queue())); connect(m_pauseAction, SIGNAL(triggered()), TransferModel::instance(), SLOT(pause())); connect(m_propertiesAction, SIGNAL(triggered()), this, SLOT(showCurrentItemProperties())); connect(m_transferQueueAction, SIGNAL(triggered()), this, SLOT(queueCurrentTransfer())); connect(m_transferPauseAction, SIGNAL(triggered()), this, SLOT(pauseCurrentTransfer())); connect(m_transferCancelAction, SIGNAL(triggered()), this, SLOT(cancelCurrentTransfer())); connect(m_transferCancelDeleteAction, SIGNAL(triggered()), this, SLOT(cancelAndDeleteCurrentTransfer())); connect(m_packageQueueAction, SIGNAL(triggered()), this, SLOT(queueCurrentPackage())); connect(m_packagePauseAction, SIGNAL(triggered()), this, SLOT(pauseCurrentPackage())); connect(m_packageCancelAction, SIGNAL(triggered()), this, SLOT(cancelCurrentPackage())); connect(m_packageCancelDeleteAction, SIGNAL(triggered()), this, SLOT(cancelAndDeleteCurrentPackage())); connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(showSettingsDialog())); connect(m_pluginsAction, SIGNAL(triggered()), this, SLOT(loadPlugins())); connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog())); connect(m_concurrentAction, SIGNAL(valueChanged(QVariant)), this, SLOT(setMaximumConcurrentTransfers(QVariant))); connect(m_nextAction, SIGNAL(valueChanged(QVariant)), this, SLOT(setNextAction(QVariant))); connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_view->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(onCurrentRowChanged(QModelIndex))); }
TransfersWindow::TransfersWindow(StackedWindow *parent) : StackedWindow(parent), m_model(new TransferModel(this)), m_view(new QTreeView(this)), m_startAction(new QAction(tr("Start all transfers"), this)), m_pauseAction(new QAction(tr("Pause all transfers"), this)), m_contextMenu(new QMenu(this)), m_transferCommandAction(m_contextMenu->addAction(tr("Set custom command"), this, SLOT(setCurrentTransferCustomCommand()))), m_transferStartAction(m_contextMenu->addAction(tr("Start"), this, SLOT(startCurrentTransfer()))), m_transferPauseAction(m_contextMenu->addAction(tr("Pause"), this, SLOT(pauseCurrentTransfer()))), m_transferCategoryMenu(m_contextMenu->addMenu(tr("Category"))), m_transferCategoryGroup(new QActionGroup(this)), m_transferPriorityMenu(m_contextMenu->addMenu(tr("Priority"))), m_transferPriorityGroup(new QActionGroup(this)), m_transferHighPriorityAction(m_transferPriorityMenu->addAction(tr("High"), this, SLOT(setCurrentTransferPriority()))), m_transferNormalPriorityAction(m_transferPriorityMenu->addAction(tr("Normal"), this, SLOT(setCurrentTransferPriority()))), m_transferLowPriorityAction(m_transferPriorityMenu->addAction(tr("Low"), this, SLOT(setCurrentTransferPriority()))), m_transferRemoveAction(m_contextMenu->addAction(tr("Remove"), this, SLOT(removeCurrentTransfer()))), m_label(new QLabel(QString("<p align='center'; style='font-size: 40px; color: %1'>%2</p>") .arg(palette().color(QPalette::Mid).name()).arg(tr("No transfers queued")), this)) { setWindowTitle(tr("Transfers")); setCentralWidget(new QWidget); m_view->setModel(m_model); m_view->setSelectionBehavior(QTreeView::SelectRows); m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_view->setEditTriggers(QTreeView::NoEditTriggers); m_view->setItemsExpandable(false); m_view->setIndentation(0); m_view->setUniformRowHeights(true); m_view->setAllColumnsShowFocus(true); m_view->setColumnHidden(1, true); QHeaderView *header = m_view->header(); if (!header->restoreState(Settings::transfersHeaderViewState())) { const QFontMetrics fm = header->fontMetrics(); header->resizeSection(0, fm.width("A long transfer name") + 10); header->resizeSection(2, fm.width(m_model->headerData(2).toString()) + 10); header->resizeSection(3, fm.width("999.99MB of 999.99MB (99.99%)") + 10); header->setSectionHidden(1, true); } m_transferCategoryGroup->setExclusive(true); m_transferPriorityGroup->setExclusive(true); m_transferHighPriorityAction->setCheckable(true); m_transferHighPriorityAction->setActionGroup(m_transferPriorityGroup); m_transferNormalPriorityAction->setCheckable(true); m_transferNormalPriorityAction->setActionGroup(m_transferPriorityGroup); m_transferLowPriorityAction->setCheckable(true); m_transferLowPriorityAction->setActionGroup(m_transferPriorityGroup); m_label->hide(); m_layout = new QVBoxLayout(centralWidget()); m_layout->addWidget(m_view); m_layout->addWidget(m_label); m_layout->setContentsMargins(0, 0, 0, 0); menuBar()->addAction(m_startAction); menuBar()->addAction(m_pauseAction); connect(m_model, SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int))); connect(m_startAction, SIGNAL(triggered()), Transfers::instance(), SLOT(start())); connect(m_pauseAction, SIGNAL(triggered()), Transfers::instance(), SLOT(pause())); connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_contextMenu, SIGNAL(aboutToShow()), this, SLOT(setTransferMenuActions())); connect(Settings::instance(), SIGNAL(categoriesChanged()), this, SLOT(setCategoryMenuActions())); onCountChanged(m_model->rowCount()); setCategoryMenuActions(); }