void Unicorn::TabBar::mouseMoveEvent( QMouseEvent* e ) { if( !m_tearable ) return; if( !(e->buttons() & Qt::LeftButton) || m_mouseDownPos.isNull() ) return; if( (e->pos() - m_mouseDownPos ).manhattanLength() < k_startTearDistance) return; TabWidget* tabWidget = qobject_cast<TabWidget*>( parentWidget() ); if( !tabWidget ) return; int index = currentIndex(); removeTab( index ); QWidget* curWidget = tabWidget->widget( index ); if( !curWidget ) return; QPoint offset = curWidget->mapToGlobal(curWidget->pos()) - QCursor::pos(); curWidget->setParent( window(), Qt::Tool ); curWidget->move( QCursor::pos() + QPoint(offset.x(), 0)); curWidget->resize( tabWidget->size()); curWidget->show(); m_tearable = false; while( QApplication::mouseButtons() & Qt::LeftButton ) { if( curWidget->pos() != QCursor::pos()) curWidget->move( QCursor::pos() + QPoint(offset.x(), 0)); QApplication::processEvents( QEventLoop::WaitForMoreEvents ); } curWidget->installEventFilter( this ); m_tearable = true; m_mouseDownPos = QPoint(); }
void FrostEdit::applySettings() { loadStyleSheet(Settings::get("Appearance/StyleSheet", "").toString()); //mSyntaxStyle.load(Settings::get("Appearance/Colorscheme").toString()); //mSettingsMenu->setSyntaxStyle(&mSyntaxStyle); mFont.setFamily(Settings::get("TextEditor/Font", "Lucida Console").toString()); mFont.setPointSize(Settings::get("TextEditor/FontSize", 10).toInt()); for(TabWidgetFrame* tabf: mTabWidgetFrames) { TabWidget* wid =tabf->tabWidget(); for(int i = 0; i < wid->count(); i++) { TextEdit* e = toTextEdit(wid->widget(i)); e->setFont(mFont); mSyntaxStyle.applyToTextEdit(e); } } for(auto i: mOpenDocuments.keys()) { Document* doc = mOpenDocuments[i]; TextEditor::Internal::Highlighter* hilt = doc->getHighlighter(); if(hilt != nullptr) { qDebug() << "Found a highlighter!"; mSyntaxStyle.applyToHighlighter(hilt); hilt->rehighlight(); } } for(int i = 0; i < mApplicationOutput->count(); i++) { Console* c = toConsole(mApplicationOutput->widget(i)); mSyntaxStyle.applyToConsole(c); } mSyntaxStyle.applyToConsole(mCompileOutput); mSyntaxStyle.applyToIssueList(mIssueList); }
/*! * Сохранение списка закреплённых вкладок и их порядка. */ void StateCache::save() { if (!m_settings->isSynced()) return; TabWidget *tabs = TabWidget::i(); for (int i = tabs->count() - 1; i >= 0; --i) { AbstractTab *tab = tabs->widget(i); if (tab->options() & AbstractTab::Pinned) { const QString id = encode(tab->id()); m_tabs.removeAll(id); m_tabs.prepend(id); } } if (ChatClient::channels()->policy() & ServerFeed::ForcedJoinPolicy) { const QString mainId = SimpleID::encode(ChatClient::channels()->mainId()); m_tabs.removeAll(mainId); m_tabs.prepend(mainId); } m_settings->setValue(m_key, m_tabs); }