FullScreenWidget::FullScreenWidget(MainWindow * mainwindow) : QWidget(0), _mainWindow(mainwindow) { setupUi(this); #if QT_VERSION >= 0x040600 _tbFoldRightPanel->setIcon( QIcon::fromTheme( "window-close") ); #else _tbFoldRightPanel->setText("Hide >>"); #endif connect(_tbFoldRightPanel,SIGNAL(clicked()), _rightFrame, SLOT(hide())); connect(_tbFoldRightPanel,SIGNAL(clicked()), _imageView, SLOT(setFocus())); connect( _imageView, SIGNAL(escapePressed()), this, SIGNAL(escapePressed()) ); connect( _imageView, SIGNAL(spaceBarPressed()), this, SIGNAL(spaceBarPressed()) ); connect( _imageView, SIGNAL( mousePress( QMouseEvent * ) ), _mainWindow, SLOT( imageViewMouseEvent( QMouseEvent * ) ) ); connect( _imageView, SIGNAL( mouseMove( QMouseEvent * ) ), _mainWindow, SLOT( imageViewMouseEvent( QMouseEvent * ) ) ); _imageView->setMouseTracking( true ); setMouseTracking(true); _rightFrame->setVisible(false); _splitter->setChildrenCollapsible(false); layout()->setContentsMargins(1,0,1,0); }
OutputWindow::OutputWindow(MainWindow * mainwindow) : QWidget(0), _mainWindow(mainwindow) { setupUi(this); #if QT_VERSION >= 0x040600 _tbFullScreen->setIcon(QIcon::fromTheme("view-fullscreen")); #else _tbFullScreen->setText("Fullscreen"); _tbFullScreen->setToolButtonStyle(Qt::ToolButtonTextOnly); #endif _pbClose->setCheckable(false); _tbFullScreen->setCheckable(true); connect( _tbFullScreen, SIGNAL(toggled(bool)), this, SLOT(onShowFullscreen(bool)) ); connect( _pbClose, SIGNAL(clicked(bool)), this, SLOT(onCloseClicked()) ); connect( _imageView, SIGNAL(escapePressed()), this, SIGNAL(escapePressed()) ); connect( _imageView, SIGNAL(spaceBarPressed()), this, SIGNAL(spaceBarPressed()) ); connect( _imageView, SIGNAL( mousePress( QMouseEvent * ) ), _mainWindow, SLOT( imageViewMouseEvent( QMouseEvent * ) ) ); connect( _imageView, SIGNAL( mouseMove( QMouseEvent * ) ), _mainWindow, SLOT( imageViewMouseEvent( QMouseEvent * ) ) ); connect( _imageView, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(onToggleFullScreen()) ); _imageView->setMouseTracking( true ); setMouseTracking(true); layout()->setContentsMargins(1,0,1,0); }
WDateEdit::WDateEdit(WContainerWidget *parent) : WLineEdit(parent) { changed().connect(this, &WDateEdit::setFromLineEdit); const char *TEMPLATE = "${calendar}"; WTemplate *t = new WTemplate(WString::fromUTF8(TEMPLATE)); popup_ = new WPopupWidget(t, this); popup_->setAnchorWidget(this); popup_->setTransient(true); calendar_ = new WCalendar(); calendar_->setSingleClickSelect(true); calendar_->activated().connect(popup_, &WPopupWidget::hide); calendar_->activated().connect(this, &WWidget::setFocus); calendar_->selectionChanged().connect(this, &WDateEdit::setFromCalendar); t->bindWidget("calendar", calendar_); WApplication::instance()->theme()->apply(this, popup_, DatePickerPopupRole); escapePressed().connect(popup_, &WPopupWidget::hide); escapePressed().connect(this, &WWidget::setFocus); setValidator(new WDateValidator("dd/MM/yyyy", this)); }
void PitchEdit::keyPressEvent(QKeyEvent* ev) { if (ev->key() == Qt::Key_Return) emit returnPressed(); else if (ev->key() == Qt::Key_Escape) emit escapePressed(); }
RDMarkerWidget::RDMarkerWidget(const QString &caption,const QColor &color, unsigned samprate,QWidget *parent) : QWidget(parent) { mark_delete_mode=false; mark_value=0; mark_sample_rate=samprate; mark_lo_limit=-1; mark_hi_limit=-1; mark_lo_marker=NULL; mark_hi_marker=NULL; QFont button_font=QFont("Hevetica",12,QFont::Bold); button_font.setPixelSize(12); QFont label_font=QFont("Hevetica",12,QFont::Normal); label_font.setPixelSize(12); mark_edit=new RDMarkerEdit(this); mark_edit->setGeometry(68,11,95,21); mark_edit->setReadOnly(true); mark_edit->setDragEnabled(false); mark_edit->setFont(label_font); connect(mark_edit,SIGNAL(returnPressed()),this,SLOT(returnPressedData())); connect(mark_edit,SIGNAL(escapePressed()),this,SLOT(escapePressedData())); mark_button=new RDMarkerButton(this); mark_button->setToggleButton(true); mark_button->setGeometry(0,0,66,45); mark_button->setFlashColor(backgroundColor()); mark_button->setFlashPeriod(RDMARKERWIDGET_BUTTON_FLASH_PERIOD); mark_button->setPalette(QPalette(color,parent->backgroundColor())); mark_button->setFont(button_font); mark_button->setText(caption); connect(mark_button,SIGNAL(clicked()),this,SLOT(buttonClickedData())); }
void FocusedTextEdit::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape) { emit escapePressed(); return; } if (m_disableUpdatesOnKeyPress) setUpdatesEnabled(false); KTextEdit::keyPressEvent(event); // Workaround (for ensuring the cursor to be visible): signal not emitted when pressing those keys: if (event->key() == Qt::Key_Home || event->key() == Qt::Key_End || event->key() == Qt::Key_PageUp || event->key() == Qt::Key_PageDown) emit cursorPositionChanged(); if (m_disableUpdatesOnKeyPress) { setUpdatesEnabled(true); if (!document()->isEmpty()) ensureCursorVisible(); } }
void RDMarkerEdit::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Qt::Key_Escape: emit escapePressed(); break; case Qt::Key_Delete: e->ignore(); return; break; case Qt::Key_Space: e->ignore(); return; break; case Qt::Key_Home: e->ignore(); return; break; case Qt::Key_End: e->ignore(); return; break; default: break; } QLineEdit::keyPressEvent(e); }
TextEditor::TextEditor(TextContent *textContent, QWidget *parent) : NoteEditor(textContent), m_textContent(textContent) { FocusedTextEdit *textEdit = new FocusedTextEdit(/*disableUpdatesOnKeyPress=*/true,parent); textEdit->setLineWidth(0); textEdit->setMidLineWidth(0); textEdit->setFrameStyle(QFrame::Box); QPalette palette; palette.setColor(textEdit->backgroundRole(), note()->backgroundColor()); palette.setColor(textEdit->foregroundRole(), note()->textColor()); textEdit->setPalette(palette); textEdit->setFont(note()->font()); textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); if (Settings::spellCheckTextNotes()) textEdit->setCheckSpellingEnabled(true); textEdit->setPlainText(m_textContent->text()); // Not sure if the following comment is still true // FIXME: Sometimes, the cursor flicker at ends before being positionned where clicked (because kapp->processEvents() I think) textEdit->moveCursor(QTextCursor::End); textEdit->verticalScrollBar()->setCursor(Qt::ArrowCursor); setInlineEditor(textEdit); connect(textEdit, SIGNAL(escapePressed()), this, SIGNAL(askValidation())); connect(textEdit, SIGNAL(mouseEntered()), this, SIGNAL(mouseEnteredEditorWidget())); connect(textEdit, SIGNAL(cursorPositionChanged()), textContent->note()->basket(), SLOT(editorCursorPositionChanged())); // In case it is a very big note, the top is displayed and Enter is pressed: the cursor is on bottom, we should enure it visible: QTimer::singleShot(0, textContent->note()->basket(), SLOT(editorCursorPositionChanged())); }
bool BookmarkWidget::eventFilter(QObject *object, QEvent *e) { if ((object == this) || (object == treeView->viewport())) { QModelIndex index = treeView->currentIndex(); if (e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent*>(e); if (index.isValid() && searchField->text().isEmpty()) { const QModelIndex &src = filterBookmarkModel->mapToSource(index); if (ke->key() == Qt::Key_F2) { QStandardItem *item = bookmarkManager->treeBookmarkModel()->itemFromIndex(src); if (item) { item->setEditable(true); treeView->edit(index); item->setEditable(false); } } else if (ke->key() == Qt::Key_Delete) { bookmarkManager->removeBookmarkItem(treeView, src); } } switch (ke->key()) { default: break; case Qt::Key_Up: { case Qt::Key_Down: treeView->subclassKeyPressEvent(ke); } break; case Qt::Key_Enter: { case Qt::Key_Return: index = treeView->selectionModel()->currentIndex(); if (index.isValid()) { QString data = index.data(Qt::UserRole + 10).toString(); if (!data.isEmpty() && data != QLatin1String("Folder")) emit requestShowLink(data); } } break; case Qt::Key_Escape: { emit escapePressed(); } break; } } else if (e->type() == QEvent::MouseButtonRelease) { if (index.isValid()) { QMouseEvent *me = static_cast<QMouseEvent*>(e); bool controlPressed = me->modifiers() & Qt::ControlModifier; if(((me->button() == Qt::LeftButton) && controlPressed) || (me->button() == Qt::MidButton)) { QString data = index.data(Qt::UserRole + 10).toString(); if (!data.isEmpty() && data != QLatin1String("Folder")) { //CentralWidget::instance()->setSourceInNewTab(data); emit requestShowLinkInNewTab(data); } } } } } return QWidget::eventFilter(object, e); }
void TextEditEx::keyPressEvent(QKeyEvent* _event) { emit keyPressed(_event->key()); if (_event->key() == Qt::Key_Backspace && toPlainText().isEmpty()) emit emptyTextBackspace(); if (_event->key() == Qt::Key_Escape) emit escapePressed(); if (_event->key() == Qt::Key_Up) emit upArrow(); if (_event->key() == Qt::Key_Down) emit downArrow(); if (_event->key() == Qt::Key_Return || _event->key() == Qt::Key_Enter) { Qt::KeyboardModifiers modifiers = _event->modifiers(); if (catch_enter(modifiers)) { emit enter(); return; } } QTextBrowser::keyPressEvent(_event); }
// -------------------------------------------------------------------------------- void QmvSelect::keyPressEvent( QKeyEvent *ev ) { if (ev->key() == Key_Escape) emit escapePressed(); else QDialog::keyPressEvent(ev); ev->accept(); }
void FontSizeCombo::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape) emit escapePressed(); else if (event->key() == Qt::Key_Return) emit returnPressed2(); else KComboBox::keyPressEvent(event); }
bool FindWidget::eventFilter(QObject *object, QEvent *e) { if (e->type() == QEvent::KeyPress) { if ((static_cast<QKeyEvent*>(e))->key() == Qt::Key_Escape) { hide(); emit escapePressed(); } } return QWidget::eventFilter(object, e); }
void FullScreenWidget::keyPressEvent( QKeyEvent * e ) { if ( e->key() == Qt::Key_Escape || e->key() == Qt::Key_F5) { emit escapePressed(); e->accept(); } if ( e->key() == Qt::Key_Space && !_rightFrame->isVisible() ) { emit spaceBarPressed(); e->accept(); } }
void ImageView::keyPressEvent( QKeyEvent * e ) { if ( e->key() == Qt::Key_Space ) { e->accept(); emit spaceBarPressed(); } if ( e->key() == Qt::Key_Escape) { emit escapePressed(); e->accept(); } }
void OutputWindow::keyPressEvent( QKeyEvent * e ) { if ( isFullScreen() && (e->key() == Qt::Key_Escape || e->key() == Qt::Key_F5) ) { onShowFullscreen(false); emit escapePressed(); e->accept(); } if ( e->key() == Qt::Key_Space ) { emit spaceBarPressed(); e->accept(); } }
WidgetContact::WidgetContact( QWidget * parent ) : QWidget( parent ), m_cachedLineMargin( 0 ), m_addressFont( QFont() ), m_cachedRowHeight( 0 ) { m_edit = new LineEdit( this ); m_edit->hide(); connect( m_edit, SIGNAL( returnPressed() ), SLOT( editReturned() ) ); connect( m_edit, SIGNAL( escapePressed() ), SLOT( editEscaped() ) ); connect( m_edit, SIGNAL( focusOut() ), SLOT( editEscaped() ) ); }
void TextEditor::keyPressEvent (QKeyEvent * event) { if (m_commaTyped && event->key() != Qt::Key_Space) { m_commaTyped = false; } switch(event->key()) { case Qt::Key_Tab: if (m_parameterMode) { emit tabPressed(); } else if(m_tabIndents) { emit requestIndent(); } else { QTextEdit::keyPressEvent(event); } return; case Qt::Key_Backtab: if (m_parameterMode) { emit backtabPressed(); } else if(m_tabIndents) { emit requestUnindent(); } return; case Qt::Key_Return: case Qt::Key_Enter: emit enterPressed(); break; case Qt::Key_Space: if (m_commaTyped) { emit showParameterInfo(); } m_commaTyped = false; break; case Qt::Key_Comma: m_commaTyped = true; break; } QTextEdit::keyPressEvent(event); // Process key events in the rest of the application if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down || event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) { emit arrowPressed(); } if (event->key() == Qt::Key_Escape) { emit escapePressed(); } else if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { emit newLine(); } return; }
void LoginWidget::keyPressEvent(QKeyEvent *e){ if( (e->key()==Qt::Key_Enter) || (e->key()==Qt::Key_Return) ){ if(userSelected){ slotTryLogin(); }else{ slotUserSelected(); } }else if(e->key() == Qt::Key_Escape){ if(userSelected){ slotUserUnselected(); }else{ emit escapePressed(); } } }
void LoginWidget::keyPressEvent(QKeyEvent *e){ if(nousers->isVisible()){ return; } if( (e->key()==Qt::Key_Enter) || (e->key()==Qt::Key_Return) ){ if(userSelected || !showUsers){ slotTryLogin(); }else{ slotUserSelected(); } }else if(e->key() == Qt::Key_Escape){ if(userSelected && showUsers){ slotUserUnselected(); }else{ emit escapePressed(); } } }
void TypingBox::keyPressEvent(QKeyEvent *event) { if(event->key()==Qt::Key_Return){ emit enterPressed(); } else if(event->key()==Qt::Key_Escape) { emit escapePressed(); } else if(event->key()==Qt::Key_Tab) { emit switchMode(); } else if(event->key()==Qt::Key_Period && (event->modifiers() & Qt::ControlModifier)) { emit showPreferences(); } else if(event->key()==Qt::Key_Z && (event->modifiers() & Qt::ControlModifier)) { emit switchColoringMode(); } else { QTextBrowser::keyPressEvent(event); } }
void NewDoc::createOpenDocPage() { PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false); QString docDir = "."; QString prefsDocDir=prefsManager->documentDir(); if (!prefsDocDir.isEmpty()) docDir = docContext->get("docsopen", prefsDocDir); else docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); openDocFrame = new QFrame(this); openDocLayout = new QVBoxLayout(openDocFrame); openDocLayout->setMargin(5); openDocLayout->setSpacing(5); m_selectedFile = ""; fileDialog = new QFileDialog(openDocFrame, tr("Open"), docDir, formats); fileDialog->setFileMode(QFileDialog::ExistingFile); fileDialog->setAcceptMode(QFileDialog::AcceptOpen); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setNameFilterDetailsVisible(false); fileDialog->setReadOnly(true); fileDialog->setSizeGripEnabled(false); fileDialog->setModal(false); QList<QPushButton *> b = fileDialog->findChildren<QPushButton *>(); QListIterator<QPushButton *> i(b); while (i.hasNext()) i.next()->setVisible(false); fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> lv = fileDialog->findChildren<QListView *>(); QListIterator<QListView *> lvi(lv); while (lvi.hasNext()) lvi.next()->installEventFilter(keyCatcher); connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject())); connect(keyCatcher, SIGNAL(dropLocation(QString)), this, SLOT(locationDropped(QString))); connect(keyCatcher, SIGNAL(desktopPressed()), this, SLOT(gotoDesktopDirectory())); connect(keyCatcher, SIGNAL(homePressed()), this, SLOT(gotoHomeDirectory())); connect(keyCatcher, SIGNAL(parentPressed()), this, SLOT(gotoParentDirectory())); connect(keyCatcher, SIGNAL(enterSelectedPressed()), this, SLOT(gotoSelectedDirectory())); connect(fileDialog, SIGNAL(filesSelected(const QStringList &)), this, SLOT(openFile())); connect(fileDialog, SIGNAL(rejected()), this, SLOT(reject())); }
FileEditor::FileEditor(FileContent *fileContent, QWidget *parent) : NoteEditor(fileContent), m_fileContent(fileContent) { KLineEdit *lineEdit = new KLineEdit(parent); FocusWidgetFilter *filter = new FocusWidgetFilter(lineEdit); QPalette palette; palette.setColor(lineEdit->backgroundRole(), note()->backgroundColor()); palette.setColor(lineEdit->foregroundRole(), note()->textColor()); lineEdit->setPalette(palette); lineEdit->setFont(note()->font()); lineEdit->setText(m_fileContent->fileName()); lineEdit->selectAll(); setInlineEditor(lineEdit); connect(filter, SIGNAL(returnPressed()), this, SIGNAL(askValidation())); connect(filter, SIGNAL(escapePressed()), this, SIGNAL(askValidation())); connect(filter, SIGNAL(mouseEntered()), this, SIGNAL(mouseEnteredEditorWidget())); }
void WidgetAddition::createWidgets() { m_editCity = new LineEdit( this ); m_editCity->setToolTip( "Измени и нажми Enter" ); connect( m_editCity, SIGNAL( returnPressed() ), SLOT( editReturned() ) ); connect( m_editCity, SIGNAL( escapePressed() ), SLOT( editEscaped() ) ); m_modelCompleter = new QStringListModel( this ); m_editCity->setCompleter( new QCompleter( m_modelCompleter, m_editCity ) ); QLabel * labelCity = new QLabel( "&Город", this ); labelCity->setBuddy( m_editCity ); QGridLayout * layout = new QGridLayout( this ); layout->addWidget( labelCity, 0, 0, Qt::AlignRight ); layout->addWidget( m_editCity, 0, 1 ); }
void SpinBox::keyPressEvent(QKeyEvent* ev) { switch (ev->key()) { case Qt::Key_Return: { bool mod = lineEdit()->isModified(); QSpinBox::keyPressEvent(ev); if(_returnMode && !mod) // Force valueChanged if return mode set, even if not modified. emit valueChanged(value()); emit returnPressed(); } return; break; case Qt::Key_Escape: emit escapePressed(); return; break; default: break; } QSpinBox::keyPressEvent(ev); }
void GuiCommandEdit::keyPressEvent(QKeyEvent * e) { switch (e->key()) { case Qt::Key_Escape: // emit signal escapePressed(); break; case Qt::Key_Up: // emit signal upPressed(); break; case Qt::Key_Down: // emit signal downPressed(); break; default: QLineEdit::keyPressEvent(e); break; } }
bool FocusWidgetFilter::eventFilter(QObject *, QEvent *e) { switch (e->type()) { case QEvent::KeyPress: { QKeyEvent *ke = static_cast<QKeyEvent*>(e); switch (ke->key()) { case Qt::Key_Return: emit returnPressed(); return true; case Qt::Key_Escape: emit escapePressed(); return true; default: return false; }; } case QEvent::Enter: emit mouseEntered(); // pass through default: return false; }; }
QT_BEGIN_NAMESPACE MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) : QMainWindow(parent) , m_bookmarkWidget(0) , m_filterCombo(0) , m_toolBarMenu(0) , m_cmdLine(cmdLine) , m_progressWidget(0) , m_qtDocInstaller(0) , m_connectedInitSignals(false) { TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); setDockOptions(dockOptions() | AllowNestedDocks); QString collectionFile; if (usesDefaultCollection()) { MainWindow::collectionFileDirectory(true); collectionFile = MainWindow::defaultHelpCollectionFileName(); } else { collectionFile = cmdLine->collectionFile(); } HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(collectionFile); BookmarkManager *bookMarkManager = BookmarkManager::instance(); if (!initHelpDB(!cmdLine->collectionFileGiven())) { qDebug("Fatal error: Help engine initialization failed. " "Error message was: %s\nAssistant will now exit.", qPrintable(HelpEngineWrapper::instance().error())); std::exit(1); } m_centralWidget = new CentralWidget(this); setCentralWidget(m_centralWidget); m_indexWindow = new IndexWindow(this); QDockWidget *indexDock = new QDockWidget(tr("Index"), this); indexDock->setObjectName(QLatin1String("IndexWindow")); indexDock->setWidget(m_indexWindow); addDockWidget(Qt::LeftDockWidgetArea, indexDock); m_contentWindow = new ContentWindow; QDockWidget *contentDock = new QDockWidget(tr("Contents"), this); contentDock->setObjectName(QLatin1String("ContentWindow")); contentDock->setWidget(m_contentWindow); addDockWidget(Qt::LeftDockWidgetArea, contentDock); m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine()); m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font() : helpEngineWrapper.browserFont()); QDockWidget *searchDock = new QDockWidget(tr("Search"), this); searchDock->setObjectName(QLatin1String("SearchWindow")); searchDock->setWidget(m_searchWindow); addDockWidget(Qt::LeftDockWidgetArea, searchDock); QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this); bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); bookmarkDock->setWidget(m_bookmarkWidget = bookMarkManager->bookmarkDockWidget()); addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this); openPagesDock->setObjectName(QLatin1String("Open Pages")); OpenPagesManager *openPagesManager = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url()); openPagesDock->setWidget(openPagesManager->openPagesWidget()); addDockWidget(Qt::LeftDockWidgetArea, openPagesDock); connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), bookMarkManager, SLOT(addBookmark(QString, QString))); connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), openPagesManager, SLOT(createPage(QUrl))); QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); setupActions(); statusBar()->show(); m_centralWidget->connectTabBar(); setupFilterToolbar(); setupAddressToolbar(); const QString windowTitle = helpEngineWrapper.windowTitle(); setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); QByteArray iconArray = helpEngineWrapper.applicationIcon(); if (iconArray.size() > 0) { QPixmap pix; pix.loadFromData(iconArray); QIcon appIcon(pix); qApp->setWindowIcon(appIcon); } else { QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png")); qApp->setWindowIcon(appIcon); } QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar")); toolBar->setObjectName(QLatin1String("Bookmark Toolbar")); bookMarkManager->setBookmarksToolbar(toolBar); // Show the widget here, otherwise the restore geometry and state won't work // on x11. show(); toolBar->hide(); toolBarMenu()->addAction(toolBar->toggleViewAction()); QByteArray ba(helpEngineWrapper.mainWindow()); if (!ba.isEmpty()) restoreState(ba); ba = helpEngineWrapper.mainWindowGeometry(); if (!ba.isEmpty()) { restoreGeometry(ba); } else { tabifyDockWidget(contentDock, indexDock); tabifyDockWidget(indexDock, bookmarkDock); tabifyDockWidget(bookmarkDock, searchDock); contentDock->raise(); const QRect screen = QApplication::desktop()->screenGeometry(); resize(4*screen.width()/5, 4*screen.height()/5); } if (!helpEngineWrapper.hasFontSettings()) { helpEngineWrapper.setUseAppFont(false); helpEngineWrapper.setUseBrowserFont(false); helpEngineWrapper.setAppFont(qApp->font()); helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); helpEngineWrapper.setBrowserFont(qApp->font()); helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); } else { updateApplicationFont(); } updateAboutMenuText(); QTimer::singleShot(0, this, SLOT(insertLastPages())); if (m_cmdLine->enableRemoteControl()) (void)new RemoteControl(this); if (m_cmdLine->contents() == CmdLineParser::Show) showContents(); else if (m_cmdLine->contents() == CmdLineParser::Hide) hideContents(); if (m_cmdLine->index() == CmdLineParser::Show) showIndex(); else if (m_cmdLine->index() == CmdLineParser::Hide) hideIndex(); if (m_cmdLine->bookmarks() == CmdLineParser::Show) showBookmarksDockWidget(); else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) hideBookmarksDockWidget(); if (m_cmdLine->search() == CmdLineParser::Show) showSearch(); else if (m_cmdLine->search() == CmdLineParser::Hide) hideSearch(); if (m_cmdLine->contents() == CmdLineParser::Activate) showContents(); else if (m_cmdLine->index() == CmdLineParser::Activate) showIndex(); else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) showBookmarksDockWidget(); if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); if (helpEngineWrapper.customFilters().contains(curFilter)) helpEngineWrapper.setCurrentFilter(curFilter); } if (usesDefaultCollection()) QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); else checkInitState(); connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), this, SLOT(documentationRemoved(QString))); connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), this, SLOT(documentationUpdated(QString))); setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); GlobalActions::instance()->updateActions(); if (helpEngineWrapper.addressBarEnabled()) showNewAddress(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // "([^"]+)"|(\S+) // ""([^""]+)""|(\\S+) //WavSound *w = new WavSound(":/resources/connected.wav", 0); //w->play(); //return; //PlaySound(); //return; ui->setupUi(this); QApplication::setWindowIcon(QIcon(":/resources/Icon/RunningIcon.png")); strangerPrefsWindow = new StrangerPrefsWindow(this); //QDockWidget *drawdock = new QDockWidget(this,Qt::Dialog); //this->addDockWidget(Qt::RightDockWidgetArea,drawdock); /*CometClient *c = new CometClient(this); c->get("http://gggoogle.ru", 6); c->get("http://gggoogle.ru", 7); c->get("http://google.ru", 8); c->get("http://googleq.ru", 9); c->cancelAllRequests(); return; */ /*QHBoxLayout *dockLayout = new QHBoxLayout(this); QComboBox *b = new QComboBox(this); QTextEdit *t = new QTextEdit(this); dockLayout->addWidget(b); dockLayout->addWidget(t); dockLayout->setSizeConstraint(QLayout::SetMinimumSize); ui->dockWidgetContents_2->setLayout(dockLayout); */ QWidget::setTabOrder(ui->typingBox, ui->chatlogBox); //do not allow Qt framework to intercept Tab keypress (we use it for switching modes) //ui->chatlogBox->setFocusPolicy(Qt::NoFocus); /*QFile stylesheetFile(":/resources/stylesheet.qss"); if(!stylesheetFile.open(QFile::ReadOnly)) { qDebug() << "Error opening file " << stylesheetFile.error(); } QString stylesheetString = QLatin1String(stylesheetFile.readAll()); setStyleSheet(stylesheetString); */ nightColoringMode = false; switchColoringMode(); //switch to night coloring mode, and apply it QStatusBar *sb = this->statusBar(); chatModeLabel = new QLabel(this); //chatModeLabel = new QPushButton(this); //chatModeLabel->setFlat(true); sb->addPermanentWidget(chatModeLabel); typingLabel = new QLabel(this); sb->addPermanentWidget(typingLabel); //center the window setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), qApp->desktop()->availableGeometry())); receivedMessageSound = NULL; sentMessageSound = NULL; connectedSound = NULL; disconnectedSound = NULL; receivedMessageSound = new QSound(":/resources/sounds/shuffle.wav", this); //sentMessageSound = new QSound(":/resources/sounds/test.wav", this); connectedSound = new QSound(":/resources/sounds/click1.wav", this); disconnectedSound = new QSound(":/resources/sounds/phone_disc.wav", this); //receivedMessageSound->setObjectName(); //return; QObject::connect(ui->typingBox, SIGNAL(enterPressed()), this, SLOT(enterPressed())); QObject::connect(ui->typingBox, SIGNAL(escapePressed()), this, SLOT(escapePressed())); QObject::connect(ui->typingBox, SIGNAL(switchMode()), this, SLOT(SwitchMode())); QObject::connect(ui->typingBox, SIGNAL(typingStarted()), this, SLOT(TypingStarted())); QObject::connect(ui->typingBox, SIGNAL(typingStopped()), this, SLOT(TypingStopped())); QObject::connect(ui->typingBox, SIGNAL(showPreferences()), this, SLOT(displayStrangerPreferencesWindow())); QObject::connect(ui->typingBox, SIGNAL(switchColoringMode()), this, SLOT(switchColoringMode())); stranger = new Stranger(this); spy = new Spy(this); rusStranger = new RusStranger(this); //rusStranger->requestChatKey(); //rusStranger->requestUid(); QObject::connect(stranger, SIGNAL(ReceivedMessage(const QString &)), this, SLOT(ReceivedMessage(const QString &))); QObject::connect(stranger, SIGNAL(StrangerDisconnected()), this, SLOT(StrangerDisconnected())); QObject::connect(stranger, SIGNAL(ConversationStarted(QStringList, bool)), this, SLOT(StrangerConnected(QStringList, bool))); //QObject::connect(stranger, SIGNAL(ConversationStarted()), this, SLOT(StrangerConnected())); QObject::connect(stranger, SIGNAL(ConversationStartedWithQuestion(QString)), this, SLOT(StrangerConnectedWithQuestion(QString))); QObject::connect(stranger, SIGNAL(StrangerStartsTyping()), this, SLOT(StrangerStartsTyping())); QObject::connect(stranger, SIGNAL(StrangerStopsTyping()), this, SLOT(StrangerStopsTyping())); QObject::connect(stranger, SIGNAL(SystemMessage(const QString &)), this, SLOT(SystemMessage(const QString &))); QObject::connect(stranger, SIGNAL(WaitingForStranger()), this, SLOT(WaitingForStranger())); QObject::connect(spy, SIGNAL(ReceivedMessage(const QString &,const QString &)), this, SLOT(SpymodeReceivedMessage(const QString &,const QString &))); QObject::connect(spy, SIGNAL(StrangerDisconnected(const QString &)), this, SLOT(SpymodeStrangerDisconnected(const QString &))); QObject::connect(spy, SIGNAL(ConversationStarted()), this, SLOT(SpymodeStrangersConnected())); QObject::connect(spy, SIGNAL(ConversationStartedWithQuestion(QString)), this, SLOT(StrangerConnectedWithQuestion(QString))); QObject::connect(spy, SIGNAL(StrangerStartsTyping(QString)), this, SLOT(SpymodeStrangerStartsTyping(const QString &))); QObject::connect(spy, SIGNAL(StrangerStopsTyping()), this, SLOT(SpymodeStrangerStopsTyping(const QString &))); QObject::connect(spy, SIGNAL(SystemMessage(const QString &)), this, SLOT(SystemMessage(const QString &))); QObject::connect(spy, SIGNAL(WaitingForStranger()), this, SLOT(WaitingForStranger())); QObject::connect(rusStranger, SIGNAL(ReceivedMessage(const QString &)), this, SLOT(ReceivedMessage(const QString &))); QObject::connect(rusStranger, SIGNAL(StrangerDisconnected()), this, SLOT(StrangerDisconnected())); QObject::connect(rusStranger, SIGNAL(ConversationStarted()), this, SLOT(StrangerConnected())); QObject::connect(rusStranger, SIGNAL(StrangerStartsTyping()), this, SLOT(StrangerStartsTyping())); QObject::connect(rusStranger, SIGNAL(StrangerStopsTyping()), this, SLOT(StrangerStopsTyping())); QObject::connect(rusStranger, SIGNAL(WaitingForStranger()), this, SLOT(WaitingForStranger())); //chatMode = Russian; chatMode = AnsweringQuestions; SwitchMode(); //switch it to regular this->escapePressed(); //strangerPrefsWindow->setModal(true); //strangerPrefsWindow->show(); }
void PCDMgui::createGUIfromTheme(){ QString style; QString tmpIcon; //used for checking image files before loading them QWidget *leftscreen = 0; for(int i=0; i<screens.length(); i++){ if(screens[i]->x()==0){ leftscreen = screens[i]; } } //Define the default icon size int perc = qRound(leftscreen->height()*0.035); //use 3.5% of the screen height defIconSize = QSize(perc,perc); //Set the background image if(DEBUG_MODE){ qDebug() << "Setting Background Image"; } if( currentTheme->itemIsEnabled("background") ){ tmpIcon = currentTheme->itemIcon("background"); if( tmpIcon.isEmpty() || !QFile::exists(tmpIcon) ){ tmpIcon = ":/images/backgroundimage.jpg"; } //use "border-image" instead of "background-image" to stretch rather than tile the image QString bgstyle = "QWidget#BGSCREEN{border-image: url(BGIMAGE) stretch;}"; bgstyle.replace("BGIMAGE", tmpIcon); style.append(bgstyle); } //Set the application style sheet style.append(" "+ currentTheme->styleSheet() ); this->setStyleSheet( style.simplified() ); //Check for whether the desktop switcher is on the toolbar or not simpleDESwitcher = (currentTheme->itemValue("desktop") == "simple"); //get the default translation directory if(DEBUG_MODE){ qDebug() << "Load Translations"; } translationDir = "/usr/local/share/pcbsd/i18n/"; //Fill the translator m_translator = new QTranslator(); //Create the Toolbar toolbar = new QToolBar(); //Add the Toolbar to the window if(DEBUG_MODE){ qDebug() << "Create Toolbar"; } //use the theme location QString tarea = currentTheme->itemValue("toolbar"); if(tarea == "left"){ this->addToolBar( Qt::LeftToolBarArea, toolbar ); }else if( tarea=="top"){ this->addToolBar( Qt::TopToolBarArea, toolbar ); toolbar->setFixedWidth(leftscreen->width()); }else if(tarea=="right"){ this->addToolBar( Qt::RightToolBarArea, toolbar ); }else{ //bottom is default this->addToolBar( Qt::BottomToolBarArea, toolbar ); toolbar->setFixedWidth(leftscreen->width()); } //Set toolbar flags toolbar->setVisible(true); toolbar->setMovable(false); toolbar->setFloatable(false); toolbar->setContextMenuPolicy(Qt::PreventContextMenu); //make sure no right-click menu //Set the default style and icon sizes QString tstyle = currentTheme->itemIcon("toolbar").toLower(); //use the theme style if(tstyle=="textonly"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly); } else if(tstyle=="textbesideicon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); } else if(tstyle=="textundericon"){ toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); } else{ toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); } //default to icon only QSize tmpsz = currentTheme->itemIconSize("toolbar"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } toolbar->setIconSize( tmpsz ); //use theme size toolbar->setFocusPolicy( Qt::NoFocus ); //Populate the Toolbar with items (starts at leftmost/topmost) //----Virtual Keyboard if(currentTheme->itemIsEnabled("vkeyboard") ){ if(DEBUG_MODE){ qDebug() << " - Create Virtual Keyboard Button"; } tmpIcon = currentTheme->itemIcon("vkeyboard"); if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/input-keyboard.png"; } virtkeyboardButton = new QAction( QIcon(tmpIcon),tr("Virtual Keyboard"),this ); toolbar->addAction(virtkeyboardButton); connect( virtkeyboardButton, SIGNAL(triggered()), this, SLOT(slotPushVirtKeyboard()) ); }else{ virtkeyboardButton = new QAction(this); } //----Locale Switcher if(DEBUG_MODE){ qDebug() << " - Create Locale Button"; } tmpIcon = currentTheme->itemIcon("locale"); if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/language.png"; } localeButton = new QAction( QIcon(tmpIcon),tr("Locale"),this ); toolbar->addAction(localeButton); connect( localeButton, SIGNAL(triggered()), this, SLOT(slotChangeLocale()) ); //----Keyboard Layout Switcher if(DEBUG_MODE){ qDebug() << " - Create Keyboard Layout Button"; } tmpIcon = currentTheme->itemIcon("keyboard"); if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/keyboard.png"; } keyboardButton = new QAction( QIcon(tmpIcon),tr("Keyboard Layout"),this ); toolbar->addAction(keyboardButton); connect( keyboardButton, SIGNAL(triggered()), this, SLOT(slotChangeKeyboardLayout()) ); //----Add a spacer QWidget* spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); toolbar->addWidget(spacer); //----System Shutdown/Restart if(DEBUG_MODE){ qDebug() << " - Create System Button"; } tmpIcon = currentTheme->itemIcon("system"); if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/system.png"; } QAction* act = new QAction( QIcon(tmpIcon),tr("System"),this ); systemButton = new QToolButton(); systemButton->setDefaultAction(act); systemMenu = new QMenu(); toolbar->addWidget(systemButton); systemButton->setPopupMode( QToolButton::InstantPopup ); systemButton->setFocusPolicy( Qt::NoFocus ); //Create the grid layout QGridLayout* grid = new QGridLayout; if(DEBUG_MODE){ qDebug() << "Fill Desktop Area"; } //Populate the grid with items //----Header Image QLabel* header = new QLabel; if( currentTheme->itemIsEnabled("header") ){ if(DEBUG_MODE){ qDebug() << " - Create Header"; } tmpIcon = currentTheme->itemIcon("header"); if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/banner.png"; } QPixmap tmp( tmpIcon ); header->setPixmap( tmp.scaled( currentTheme->itemIconSize("header") ) ); grid->addWidget( header, currentTheme->itemLocation("header","row"), \ currentTheme->itemLocation("header","col"), \ currentTheme->itemLocation("header","rowspan"), \ currentTheme->itemLocation("header","colspan"), Qt::AlignCenter); } //Username/Password/Login widget if(DEBUG_MODE){ qDebug() << " - Create Login Widget"; } loginW = new LoginWidget; /*loginW->setUsernames(Backend::getSystemUsers()); //add in the detected users QString lastUser = Backend::getLastUser(); if(!lastUser.isEmpty()){ //set the previously used user loginW->setCurrentUser(lastUser); }*/ //Set Icons from theme tmpIcon = currentTheme->itemIcon("login"); tmpsz = currentTheme->itemIconSize("login"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/next.png"; } loginW->changeButtonIcon("login",tmpIcon, tmpsz); tmpIcon = currentTheme->itemIcon("anonlogin"); tmpsz = currentTheme->itemIconSize("login"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/next-stealth.png"; } loginW->changeButtonIcon("anonlogin", tmpIcon, tmpsz); tmpIcon = currentTheme->itemIcon("user"); slotUserChanged(loginW->currentUsername()); //Make sure that we have the correct user icon tmpIcon = currentTheme->itemIcon("password"); tmpsz = currentTheme->itemIconSize("password"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/password.png"; } loginW->changeButtonIcon("pwview",tmpIcon, tmpsz); tmpIcon = currentTheme->itemIcon("encdevice"); tmpsz = currentTheme->itemIconSize("device"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } if(!QFile::exists(tmpIcon) || tmpIcon.isEmpty() ){ tmpIcon=":/images/usbdevice.png"; } loginW->changeButtonIcon("device", tmpIcon, tmpsz); //Enable/disable the password view functionality loginW->allowPasswordView( Config::allowPasswordView() ); loginW->allowUserSelection( Config::allowUserSelection() ); loginW->allowAnonLogin( Config::allowAnonLogin() ); //Add item to the grid grid->addWidget( loginW, currentTheme->itemLocation("login","row"), \ currentTheme->itemLocation("login","col"), \ currentTheme->itemLocation("login","rowspan"), \ currentTheme->itemLocation("login","colspan"), Qt::AlignCenter); //Connect the signals/slots connect(loginW,SIGNAL(loginRequested(QString,QString)),this,SLOT(slotStartLogin(QString,QString))); connect(loginW,SIGNAL(escapePressed()),this,SLOT(slotShutdownComputer())); connect(loginW,SIGNAL(UserSelected(QString)), this, SLOT(slotUserSelected(QString)) ); connect(loginW,SIGNAL(UserChanged(QString)), this, SLOT(slotUserChanged(QString)) ); //----Desktop Environment Switcher if(simpleDESwitcher){ tmpsz = currentTheme->itemIconSize("desktop"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } loginW->setDesktopIconSize(tmpsz); }else{ if(DEBUG_MODE){ qDebug() << " - Create DE Switcher"; } //Create the switcher deSwitcher = new FancySwitcher(this, !currentTheme->itemIsVertical("desktop") ); tmpsz = currentTheme->itemIconSize("desktop"); if(!tmpsz.isValid()){ tmpsz = defIconSize; } deSwitcher->setIconSize(tmpsz.height()); tmpIcon = currentTheme->itemIcon("nextde"); if( !tmpIcon.isEmpty() && QFile::exists(tmpIcon) ){ deSwitcher->changeButtonIcon("forward", tmpIcon); } tmpIcon = currentTheme->itemIcon("previousde"); if( !tmpIcon.isEmpty() && QFile::exists(tmpIcon) ){ deSwitcher->changeButtonIcon("back", tmpIcon); } //Figure out if we need to smooth out the animation deSwitcher->setNumberAnimationFrames("4"); //NOTE: A transparent widget background slows the full animation to a crawl with a stretched background image grid->addWidget( deSwitcher, currentTheme->itemLocation("desktop","row"), \ currentTheme->itemLocation("desktop","col"), \ currentTheme->itemLocation("desktop","rowspan"), \ currentTheme->itemLocation("desktop","colspan"), Qt::AlignCenter); } //----WINDOW SPACERS QStringList spacers = currentTheme->getSpacers(); for(int i=0; i<spacers.length(); i++){ bool isVertical = (spacers[i].section("::",0,0) == "true"); int row = spacers[i].section("::",1,1).toInt(); int col = spacers[i].section("::",2,2).toInt(); //qDebug() << "Add Spacer:" << isVertical << row << col; if(isVertical){ grid->setRowStretch(row,1); }else{ //horizontal grid->setColumnStretch(col,1); } } //Connect the grid to the leftmost screen widget leftscreen->setLayout(grid); //Now translate the UI and set all the text if(DEBUG_MODE){ qDebug() << " - Fill GUI with data"; } //retranslateUi(); LoadAvailableUsers(); //Note: this is the first time it is run if(DEBUG_MODE){ qDebug() << " - Translate GUI"; } retranslateUi(); if(DEBUG_MODE){ qDebug() << "Done with initialization"; } }