LogDock::LogDock(QWidget *parent) : QWidget(parent) { settings.beginGroup("LogDock"); bool autoSave = settings.value("AutoSave", false).toBool(); currLogSize = settings.value("LogSize", 1).toInt(); settings.endGroup(); // lastProbe variable for reject loop when log overflow is occurred // see for LogDock::saveLogToFile() lastProbe = true; setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); int _size = this->fontInfo().pixelSize(); currentTime = new QLabel(this); logSize = new QSpinBox(this); logSize->setToolTip("Size of Log (MB)"); logSize->setRange(1, 100); logSize->setSuffix("MB"); logSize->setValue(currLogSize); autoSaveLog = new QCheckBox(this); autoSaveLog->setToolTip("AutoSave"); saveLog = new QPushButton( QIcon::fromTheme("document-save"), "", this); saveLog->setToolTip("Save Log to File"); //saveLog->setMaximumSize(QSize(_size, _size)); titleLayout = new QHBoxLayout(); titleLayout->addWidget(currentTime, 0, Qt::AlignRight); titleLayout->addStretch(-1); titleLayout->addWidget(logSize, 0, Qt::AlignRight); titleLayout->addWidget(autoSaveLog, 0, Qt::AlignRight); titleLayout->addWidget(saveLog, 0, Qt::AlignRight); title = new QWidget(this); title->setLayout(titleLayout); titleLayout->setMargin(0); title->setContentsMargins(0, 0, 10, 0); Log = new TextBrowser(this); Log->setToolTip(QString( "Event/Error Log\nMaxSize:\t%1 Bytes\nCurrent:\t%2") .arg(currLogSize * ONE_MB) .arg(Log->toPlainText().count())); connect(Log, SIGNAL(anchorClicked(QUrl)), this, SLOT(openLink(QUrl))); docLayout = new QVBoxLayout(this); docLayout->addWidget(title); docLayout->addWidget(Log); setLayout(docLayout); docLayout->setMargin(0); setContentsMargins(0, 0, 0, 0); timerId = startTimer(1000); connect(logSize, SIGNAL(valueChanged(int)), this, SLOT(changeLogSize(int))); connect(autoSaveLog, SIGNAL(toggled(bool)), saveLog, SLOT(setDisabled(bool))); connect(saveLog, SIGNAL(clicked()), this, SLOT(_saveLogToFile())); autoSaveLog->setChecked(autoSave); }
Comments::Comments(QWidget *pParent, const char *name) : QWidget(pParent) { setObjectName(name); _source = Uninitialized; _sourceid = -1; _editable = true; _verboseCommentList = false; QVBoxLayout *vbox = new QVBoxLayout(this); QHBoxLayout *hbox = new QHBoxLayout(); hbox->setMargin(0); hbox->setSpacing(7); _verbose = new XCheckBox(tr("Verbose Text"), this); _verbose->setObjectName("_verbose"); _verboseCommentList = _verbose->isChecked(); vbox->addWidget(_verbose); vbox->addLayout(hbox); QWidget *buttons = new QWidget(this); QVBoxLayout * buttonsLayout = new QVBoxLayout(buttons); buttonsLayout->setMargin(0); buttonsLayout->setSpacing(0); _comment = new XTreeWidget(this); _comment->setObjectName("_comment"); _comment->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); _comment->addColumn(tr("Date/Time"), _timeDateColumn, Qt::AlignCenter,true, "comment_date"); _comment->addColumn(tr("Type"), _itemColumn, Qt::AlignCenter,true, "type"); _comment->addColumn(tr("Source"), _itemColumn, Qt::AlignCenter,true, "comment_source"); _comment->addColumn(tr("User"), _userColumn, Qt::AlignCenter,true, "comment_user"); _comment->addColumn(tr("Comment"), -1, Qt::AlignLeft, true, "first"); _comment->addColumn(tr("Public"), _ynColumn, Qt::AlignLeft, false, "comment_public"); hbox->addWidget(_comment); _browser = new QTextBrowser(this); _browser->setObjectName("_browser"); _browser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); _browser->setOpenLinks(false); hbox->addWidget(_browser); _newComment = new QPushButton(tr("New"), buttons); _newComment->setObjectName("_newComment"); buttonsLayout->addWidget(_newComment); _viewComment = new QPushButton(tr("View"), buttons); _viewComment->setObjectName("_viewComment"); _viewComment->setEnabled(FALSE); buttonsLayout->addWidget(_viewComment); _editComment = new QPushButton(tr("Edit"), buttons); _editComment->setObjectName("_editComment"); _editComment->setEnabled(false); buttonsLayout->addWidget(_editComment); QSpacerItem *_buttonSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); buttonsLayout->addItem(_buttonSpacer); buttons->setLayout(buttonsLayout); hbox->addWidget(buttons); _editmap = new QMultiMap<int, bool>(); _editmap2 = new QMultiMap<int, bool>(); connect(_newComment, SIGNAL(clicked()), this, SLOT( sNew())); connect(_viewComment, SIGNAL(clicked()), this, SLOT( sView())); connect(_editComment, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_comment, SIGNAL(valid(bool)), this, SLOT(sCheckButtonPriv(bool))); connect(_comment, SIGNAL(itemSelected(int)), _viewComment, SLOT(animateClick())); connect(_browser, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); connect(_verbose, SIGNAL(toggled(bool)), this, SLOT(setVerboseCommentList(bool))); setFocusProxy(_comment); setVerboseCommentList(_verboseCommentList); }
void MainWindow::urlClicked() { anchorClicked(QUrl(static_cast<QAction*>(sender())->text())); }
QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent) : QWidget(parent), c(connection), objectPathRegExp(QLatin1String("\\[ObjectPath: (.*)\\]")) { servicesModel = new QStringListModel(this); servicesFilterModel = new QSortFilterProxyModel(this); servicesFilterModel->setSourceModel(servicesModel); servicesFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); serviceFilterLine = new QLineEdit(this); serviceFilterLine->setPlaceholderText(tr("Search...")); servicesView = new QListView(this); servicesView->setModel(servicesFilterModel); connect(serviceFilterLine, SIGNAL(textChanged(QString)), servicesFilterModel, SLOT(setFilterFixedString(QString))); tree = new QTreeView; tree->setContextMenuPolicy(Qt::CustomContextMenu); connect(tree, SIGNAL(activated(QModelIndex)), this, SLOT(activate(QModelIndex))); refreshAction = new QAction(tr("&Refresh"), tree); refreshAction->setData(42); // increase the amount of 42 used as magic number by one refreshAction->setShortcut(QKeySequence::Refresh); connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshChildren())); QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, tree); connect(refreshShortcut, SIGNAL(activated()), this, SLOT(refreshChildren())); QVBoxLayout *layout = new QVBoxLayout(this); QSplitter *topSplitter = new QSplitter(Qt::Vertical, this); layout->addWidget(topSplitter); log = new QTextBrowser; connect(log, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); QSplitter *splitter = new QSplitter(topSplitter); splitter->addWidget(servicesView); QWidget *servicesWidget = new QWidget; QVBoxLayout *servicesLayout = new QVBoxLayout(servicesWidget); servicesLayout->addWidget(serviceFilterLine); servicesLayout->addWidget(servicesView); splitter->addWidget(servicesWidget); splitter->addWidget(tree); topSplitter->addWidget(splitter); topSplitter->addWidget(log); connect(servicesView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(serviceChanged(QModelIndex))); connect(tree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); if (c.isConnected()) { logMessage(QLatin1String("Connected to D-Bus.")); QDBusConnectionInterface *iface = c.interface(); connect(iface, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered(QString))); connect(iface, SIGNAL(serviceUnregistered(QString)), this, SLOT(serviceUnregistered(QString))); connect(iface, SIGNAL(serviceOwnerChanged(QString,QString,QString)), this, SLOT(serviceOwnerChanged(QString,QString,QString))); } else { logError(QLatin1String("Cannot connect to D-Bus: ") + c.lastError().message()); } objectPathRegExp.setMinimal(true); }
TextRoom::TextRoom(QWidget *parent, Qt::WFlags f) : QWidget(parent, f), sentenceTally(0) { setupUi(this); setObjectName("textroom"); // Set the default values for variables. numChanges = 0; prevLength = 0; wordcount = 0; alarm = 0; parasold = 0; isHighlighted = false; #ifdef Q_OS_MACX // Find the path for the app path QDir tmpDir = QDir(QCoreApplication::applicationDirPath()); // go into Resources folder tmpDir.cdUp(); tmpDir.cd("Resources"); // get the full path for the resources resourcesDir = tmpDir.path(); #endif // Create the dialog windows. optionsDialog = new OptionsDialog(this); helpDialog = new HelpDialog(this); selectFont = new SelectFont(this); aboutDialog = new AboutDialog(this); scratchDialog = new ScratchDialog(this); miniFlo = new MiniFlo(this); getAWord = new GetAWord(this); musicRoom = new MusicRoom(this); googleDocsDialog = new GoogleDocsDialog(this); // Read settings saved by Options Dialog. #ifdef Q_OS_WIN32 settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationName()); #else settings = new QSettings(); #endif readSettings(); // Sound adjustments. int audio_rate = 11025; Uint16 audio_format = AUDIO_S16SYS; int audio_channels = 2; int audio_buffers = 1024; if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) { printf("Unable to initialize audio: %s\n", Mix_GetError()); exit(1); } // Load sounds. #ifdef Q_OS_WIN32 soundenter = Mix_LoadWAV("keyenter.wav"); #elif defined(Q_OS_MACX) QString tmp = resourcesDir; tmp.append("/sounds/keyenter.wav"); soundenter = Mix_LoadWAV(tmp.toAscii()); #else soundenter = Mix_LoadWAV("/usr/share/sounds/keyenter.wav"); #endif if(soundenter == NULL) { printf("Unable to load WAV file: %s\n", Mix_GetError()); } #ifdef Q_OS_WIN32 soundany = Mix_LoadWAV("keyany.wav"); #elif defined(Q_OS_MACX) tmp = resourcesDir; tmp.append("/sounds/keyany.wav"); soundany = Mix_LoadWAV(tmp.toAscii()); #else soundany = Mix_LoadWAV("/usr/share/sounds/keyany.wav"); #endif if(soundany == NULL) { printf("Unable to load WAV file: %s\n", Mix_GetError()); } // Create the keyboard shortcuts. new QShortcut ( QKeySequence(QKeySequence::New), this, SLOT( newFile() ) ); new QShortcut ( QKeySequence(QKeySequence::Open), this, SLOT( open() ) ); new QShortcut ( QKeySequence(QKeySequence::Save), this, SLOT( save() ) ); new QShortcut ( QKeySequence(QKeySequence::HelpContents), this, SLOT( help() ) ); #ifdef Q_OS_MACX new QShortcut ( QKeySequence(tr("F1", "Help")), this, SLOT( help() ) ); #endif new QShortcut ( QKeySequence(tr("F2", "Options")), this, SLOT( options() ) ); new QShortcut ( QKeySequence(tr("F3", "About")), this, SLOT( about() ) ); new QShortcut ( QKeySequence(tr("F5", "Spell Check")), this, SLOT( spellCheck() ) ); new QShortcut ( QKeySequence(tr("F6", "Scratch Pad")), this, SLOT( showScratchPad() ) ); new QShortcut ( QKeySequence(tr("Ctrl+P", "Print")), this, SLOT( print() ) ); new QShortcut ( QKeySequence(tr("Shift+Ctrl+S", "Save As")), this, SLOT( saveAs() ) ); new QShortcut ( QKeySequence(tr("Ctrl+D", "Insert Date")), this, SLOT( insertDate() ) ); new QShortcut ( QKeySequence(tr("Ctrl+T", "Insert Time")), this, SLOT( insertTime() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Q", "Quit Application")) , this, SLOT( close() ) ); new QShortcut ( QKeySequence(tr("Alt+F4", "Quit Application")) , this, SLOT( close() ) ); new QShortcut ( QKeySequence(tr("Ctrl+F", "Find Text")) , this, SLOT( find() ) ); new QShortcut ( QKeySequence(tr("F11", "Toggle Fullscreen")) , this, SLOT( toggleFullScreen() ) ); new QShortcut ( QKeySequence(tr("Esc", "Toggle Fullscreen")) , this, SLOT( toggleEscape() ) ); new QShortcut ( QKeySequence(tr("Ctrl+M", "Minimize TextRoom")) , this, SLOT( showMinimized() ) ); new QShortcut ( QKeySequence(tr("F4", "Find Next")) , this, SLOT( find_next() ) ); new QShortcut ( QKeySequence(tr("Ctrl+F4", "Find Previous")) , this, SLOT( find_previous() ) ); new QShortcut ( QKeySequence(tr("Ctrl+B", "Bold")) , this, SLOT( textBold() ) ); new QShortcut ( QKeySequence(tr("Ctrl+I", "Italic")) , this, SLOT( textItalic() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Up", "Increase Text Size")) , this, SLOT( textSizeUp() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Down", "Decrease Text Size")) , this, SLOT( textSizeDown() ) ); new QShortcut ( QKeySequence(tr("Ctrl+W", "Select Font")) , this, SLOT( changeFont() ) ); new QShortcut ( QKeySequence(tr("Ctrl+R", "Align Right")) , this, SLOT( alignRight() ) ); new QShortcut ( QKeySequence(tr("Ctrl+L", "Align Left")) , this, SLOT( alignLeft() ) ); new QShortcut ( QKeySequence(tr("Ctrl+J", "Align Justify")) , this, SLOT( alignJustify() ) ); new QShortcut ( QKeySequence(tr("Ctrl+E", "Align Center")) , this, SLOT( alignCenter() ) ); new QShortcut ( QKeySequence(tr("Ctrl+Alt+I", "Insert Image")) , this, SLOT( insertImage() ) ); new QShortcut ( QKeySequence(tr("F7", "Show MiniFlo")) , this, SLOT( showMiniFlo() ) ); new QShortcut ( QKeySequence(tr("F8", "Get A Word")) , this, SLOT( showGetAWord() ) ); new QShortcut ( QKeySequence(tr("F9", "MusicRoom")) , this, SLOT( showMusicRoom() ) ); new QShortcut ( QKeySequence(tr("F10", "Google Docs")) , this, SLOT( exportToGoogle() ) ); // Service: show cursor new QShortcut ( QKeySequence(tr("Shift+F4", "Show Cursor")) , this, SLOT( sCursor() ) ); //fw = new QFileSystemWatcher(this); //fw->addPath( settings->fileName() ); // If file is changed, read the settings-> //connect(fw, SIGNAL(fileChanged(const QString)), // this, SLOT(readSettings())); // If the document is changed, do some stuff. connect(textEdit->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified())); // If position is changed, scroll. connect(textEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(vPositionChanged())); // If horizontal scrollar is changed, scroll. connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(hSliderPositionChanged())); connect(textEdit, SIGNAL(anchorClicked(QUrl)), this, SLOT(showScratchPad())); // check if we need to open some file at startup const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) { QFile file( args.at(1) ); if ( file.exists() ) curFile = args.at(1); } if (!curFile.isEmpty()) loadFile(curFile); else newFile(); // set cursor position if ( isSaveCursor ) { textEdit->textCursor().setPosition(cPosition); } writeSettings(); // Refresh the file status every second. QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(getFileStatus())); timer->start(1000); }
Thesaurus::Thesaurus() { m_standAlone = false; m_thesProc = new KProcess; m_wnProc = new KProcess; m_dialog = new KoDialog(0); m_dialog->setButtons(KoDialog::Help | KoDialog::Ok | KoDialog::Cancel); m_dialog->setDefaultButton(KoDialog::Ok); m_dialog->setHelp(QString(), "thesaurus"); m_dialog->resize(600, 400); KConfigGroup cfg = KSharedConfig::openConfig()->group(""); m_dataFile = cfg.readEntry("datafile"); if (m_dataFile.isEmpty()) m_dataFile = KoResourcePaths::findResource("data", "calligra/thesaurus/thesaurus.txt"); setCaption(); m_noMatch = i18n("(No match)"); m_historyPos = 1; QWidget *page = new QWidget(); m_dialog->setMainWidget(page); QVBoxLayout *topLayout = new QVBoxLayout(page); QHBoxLayout *row1 = new QHBoxLayout; topLayout->addLayout(row1); m_edit = new KHistoryComboBox(page); QLabel editLabel(i18n("&Search for:"), page); editLabel.setBuddy(m_edit); m_search = new QPushButton(i18n("S&earch"), page); connect(m_search, SIGNAL(clicked()), this, SLOT(slotFindTerm())); row1->addWidget(&editLabel, 0); row1->addWidget(m_edit, 1); row1->addWidget(m_search, 0); m_back = new QToolButton(page); m_back->setIcon(koIcon("go-previous")); m_back->setToolTip(i18nc("@action:button Go back to the previous word in history", "Back")); row1->addWidget(m_back, 0); m_forward = new QToolButton(page); m_forward->setIcon(koIcon("go-next")); m_forward->setToolTip(i18nc("@action:button Go forward to the next word in history", "Forward")); row1->addWidget(m_forward, 0); QPushButton *lang = new QPushButton(i18n("Change Language..."), page); connect(lang, SIGNAL(clicked()), this, SLOT(slotChangeLanguage())); row1->addWidget(lang, 0); connect(m_back, SIGNAL(clicked()), this, SLOT(slotBack())); connect(m_forward, SIGNAL(clicked()), this, SLOT(slotForward())); m_tabWidget = new QTabWidget(page); topLayout->addWidget(m_tabWidget); // // Thesaurus Tab // QWidget *thesWidget = new QWidget(m_tabWidget); m_tabWidget->addTab(thesWidget, i18n("&Thesaurus")); QHBoxLayout *thesLayout = new QHBoxLayout; thesWidget->setLayout(thesLayout); QGroupBox *synGroupBox = new QGroupBox(i18n("Synonyms"), thesWidget); QHBoxLayout *synLayout = new QHBoxLayout(); synGroupBox->setLayout(synLayout); m_synListWidget = new QListWidget(synGroupBox); synLayout->addWidget(m_synListWidget); thesLayout->addWidget(synGroupBox); QGroupBox *hyperGroupBox = new QGroupBox(i18n("More General Words"), thesWidget); QHBoxLayout *hyperLayout = new QHBoxLayout(); hyperGroupBox->setLayout(hyperLayout); m_hyperListWidget = new QListWidget(hyperGroupBox); hyperLayout->addWidget(m_hyperListWidget); thesLayout->addWidget(hyperGroupBox); QGroupBox *hypoGroupBox = new QGroupBox(i18n("More Specific Words"), thesWidget); QHBoxLayout *hypoLayout = new QHBoxLayout(); hypoGroupBox->setLayout(hypoLayout); m_hypoListWidget = new QListWidget(hypoGroupBox); hypoLayout->addWidget(m_hypoListWidget); thesLayout->addWidget(hypoGroupBox); // single click -- keep display unambiguous by removing other selections: connect(m_synListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotSetReplaceTermSyn(QListWidgetItem*))); connect(m_hyperListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotSetReplaceTermHyper(QListWidgetItem*))); connect(m_hypoListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotSetReplaceTermHypo(QListWidgetItem*))); // double click -- set the double clicked item as the new search term connect(m_synListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotFindTermFromList(QListWidgetItem*))); connect(m_hyperListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotFindTermFromList(QListWidgetItem*))); connect(m_hypoListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotFindTermFromList(QListWidgetItem*))); // // WordNet Tab // QWidget *wnWidget = new QWidget(m_tabWidget); m_tabWidget->addTab(wnWidget, i18n("&Wordnet")); QVBoxLayout *wnLayout = new QVBoxLayout; wnWidget->setLayout(wnLayout); m_wnComboBox = new KComboBox(wnWidget); m_wnComboBox->setEditable(false); wnLayout->addWidget(m_wnComboBox); connect(m_wnComboBox, SIGNAL(activated(int)), this, SLOT(slotFindTerm())); m_resultTextBrowser = new QTextBrowser(wnWidget); m_resultTextBrowser->setReadOnly(true); connect(m_resultTextBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(slotFindTermFromUrl(QUrl))); wnLayout->addWidget(m_resultTextBrowser); // Connect for the history box m_edit->setTrapReturnKey(true); // Do not use Return as default key... connect(m_edit, SIGNAL(returnPressed()), this, SLOT(slotFindTerm())); connect(m_edit, SIGNAL(activated(int)), this, SLOT(slotGotoHistory(int))); QHBoxLayout *row2 = new QHBoxLayout( /*m_top_layout*/ ); topLayout->addLayout(row2); m_replaceLineEdit = new QLineEdit(page); m_replaceLabel = new QLabel(i18n("&Replace with:"), page); m_replaceLabel->setBuddy(m_replaceLineEdit); row2->addWidget(m_replaceLabel, 0); row2->addWidget(m_replaceLineEdit, 1); // Set focus m_edit->setFocus(); updateNavButtons(); connect(m_dialog, SIGNAL(accepted()), this, SLOT(process())); connect(m_dialog, SIGNAL(rejected()), this, SLOT(dialogClosed())); }
TextBrowser::TextBrowser(QWidget *parent) : QTextBrowser(parent) { this->viewport()->setCursor(Qt::IBeamCursor); setOpenLinks(false); // also disables external links connect(this,SIGNAL(anchorClicked(QUrl)),this,SLOT(openLinkInBrowser(QUrl))); // because all links should be opened in the web browser }
ChatWindow::ChatWindow(Account* account, ChatSession* s, EmoticonSelector* emoticonSelector, MultSelector* multSelector) : QWidget(), m_account(account), session(s), messageEditor(0), smsEditor(0), flashPlayer(0) { qDebug() << Q_FUNC_INFO << "{"; transferStatus = None; QVBoxLayout* layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); isNewMessage = false; connect(s->contact(), SIGNAL(renamed(QString)), this, SLOT(contactUpdated())); connect(s->contact(), SIGNAL(ignoredChanged()), this, SLOT(contactIgnored())); timer = new QTimer(this); timer->setSingleShot(true); connect(timer, SIGNAL(timeout()), this, SLOT(slotTimeout())); QHBoxLayout* mainLayout = new QHBoxLayout; splitter = new QSplitter(Qt::Vertical, this); QWidget* chatWidget = new QWidget; QHBoxLayout* chatWidgetLayout = new QHBoxLayout; chatWidgetLayout->setContentsMargins(1, 1, 1, 1); chatWidgetLayout->setSpacing(1); QToolBar* topToolbar = new QToolBar; QAction* games = new QAction(QIcon(), "", this); games->setCheckable(true); connect(games, SIGNAL(triggered(bool)), this, SLOT(showGameMenu(bool))); topToolbar->addAction(games); layout->addWidget(topToolbar); chatView = new AnimatedTextBrowser; chatWidgetLayout->addWidget(chatView); connect(chatView, SIGNAL(anchorClicked(QUrl)), this, SLOT(slotAnchorClicked(QUrl))); if (!s->contact()->isPhone() && !session->contact()->isConference()) { AvatarBoxWithHandle* avatarBoxWithHandle = new AvatarBoxWithHandle(m_account->avatarsPath(), session->contact()->email()); avatarBoxWithHandle->toggle(m_account->settings()->value("ChatWindow/TopAvatarBoxState", false).toBool()); connect(avatarBoxWithHandle, SIGNAL(toggled(bool)), SLOT(saveTopAvatarBoxState(bool))); chatWidgetLayout->addWidget(avatarBoxWithHandle); } chatWidget->setLayout(chatWidgetLayout); splitter->addWidget(chatWidget); if (!s->contact()->isPhone()) { QWidget* bottomWidget = new QWidget; QHBoxLayout* bottomWidgetLayout = new QHBoxLayout; bottomWidgetLayout->setContentsMargins(1, 1, 1, 1); bottomWidgetLayout->setSpacing(1); editorsWidget = new QTabWidget; editorsWidget->setStyleSheet("QTabWidget::pane { border: 0px; } QTabWidget::tab-bar { left: 1px; } QTabBar::tab { padding: 0px 32px 0px 32px; font: bold 9px; }"); editorsWidget->setTabPosition(QTabWidget::South); editorsWidget->setTabShape(QTabWidget::Triangular); messageEditor = new MessageEditor(m_account, session->contact(), emoticonSelector, multSelector); connect(messageEditor, SIGNAL(sendPressed()), this, SLOT(sendMessage())); connect(messageEditor, SIGNAL(textChanged()), session, SLOT(sendTyping())); connect(messageEditor, SIGNAL(wakeupPressed()), this, SLOT(wakeupContact())); connect(messageEditor, SIGNAL(showMult(const QString&)), this, SLOT(sendMult(const QString&))); connect(this, SIGNAL(messageEditorActivate()), messageEditor, SLOT(messageEditorActivate())); connect(messageEditor, SIGNAL(setIgnore(bool)), this, SIGNAL(setIgnore(bool))); connect(this, SIGNAL(ignoreSet(bool)), messageEditor, SLOT(slotIgnoreSet(bool))); connect(messageEditor, SIGNAL(setSignalCheckSpelling(bool)), this, SIGNAL(setSignalCheckSpelling(bool))); connect(this, SIGNAL(signalCheckSpellingSet(bool)), messageEditor, SLOT(setCheckSpelling(bool))); fileMessageOut = new FileMessage(FileMessage::Outgoing, this); fileMessageIn = new FileMessage(FileMessage::Incoming, this); fileMessageIn->setAccEmail(account->email()); fileMessageIn->setContEmail(session->contact()->email()); fileMessageOut->setAccEmail(account->email()); fileMessageOut->setContEmail(session->contact()->email()); connect(fileMessageOut, SIGNAL(fileTransferred(FileMessage::Status, QString, QString)), this, SLOT(slotFileTransferred(FileMessage::Status, QString, QString))); connect(fileMessageOut, SIGNAL(progress(FileMessage::Status, int)), messageEditor, SLOT(slotProgress(FileMessage::Status, int))); connect(fileMessageIn, SIGNAL(startTransferring(quint32)), this, SLOT(transferStarted(quint32))); connect(fileMessageIn, SIGNAL(fileTransferred(FileMessage::Status, QString, QString)), this, SLOT(slotFileTransferred(FileMessage::Status, QString, QString))); connect(fileMessageIn, SIGNAL(progress(FileMessage::Status, int)), messageEditor, SLOT(slotProgress(FileMessage::Status, int))); connect(m_account->client(), SIGNAL(fileTransferAck(quint32, QByteArray, quint32, QByteArray)), fileMessageOut, SLOT(slotFileTransferStatus(quint32, QByteArray, quint32, QByteArray))); connect(m_account->client(), SIGNAL(proxyAck(quint32, QByteArray, quint32, quint32, QByteArray, QByteArray, quint32, quint32, quint32, quint32)), fileMessageOut, SLOT(slotProxyAck(quint32, QByteArray, quint32, quint32, QByteArray, QByteArray, quint32, quint32, quint32, quint32))); connect(m_account->client(), SIGNAL(fileTransferAck(quint32, QByteArray, quint32, QByteArray)), fileMessageIn, SLOT(slotFileTransferStatus(quint32, QByteArray, quint32, QByteArray))); connect(m_account->client(), SIGNAL(proxy(QByteArray, quint32, quint32, QByteArray, QByteArray, quint32, quint32, quint32, quint32)), fileMessageIn, SLOT(slotProxy(QByteArray, quint32, quint32, QByteArray, QByteArray, quint32, quint32, quint32, quint32))); connect(messageEditor, SIGNAL(transferringCancel()), this, SLOT(transferringCancelled())); editorsWidget->addTab(messageEditor, tr("Text")); if (!session->contact()->isConference()) { smsEditor = new SmsEditor(m_account, session->contact()); connect(smsEditor, SIGNAL(sendPressed()), this, SLOT(sendSms())); editorsWidget->addTab(smsEditor, tr("SMS")); connect(editorsWidget, SIGNAL(currentChanged(int)), this, SLOT(slotEditorActivate(int))); }
void SoundCloudPlaylistWindow::loadBaseUi() { setWindowTitle(tr("Set")); setCentralWidget(new QWidget); m_view->setModel(m_model); m_view->setItemDelegate(m_delegate); m_view->setContextMenuPolicy(Qt::CustomContextMenu); m_thumbnail->setFixedSize(320, 320); m_thumbnail->setFallbackSource(QUrl::fromLocalFile("/usr/share/icons/hicolor/295x295/hildon/mediaplayer_default_album.png")); m_avatar->setFixedSize(60, 60); m_avatar->setFallbackSource(QUrl::fromLocalFile("/usr/share/icons/hicolor/64x64/hildon/general_default_avatar.png")); m_titleLabel->setWordWrap(true); m_dateLabel->setStyleSheet(QString("color: %1; font-size: 13pt").arg(palette().color(QPalette::Mid).name())); m_artistLabel->setStyleSheet("font-size: 13pt"); m_noTracksLabel->hide(); m_reloadAction->setEnabled(false); m_contextMenu->addAction(m_queueAction); m_contextMenu->addAction(m_downloadAction); m_contextMenu->addAction(m_shareAction); QWidget *scrollWidget = new QWidget(m_scrollArea); QGridLayout *grid = new QGridLayout(scrollWidget); grid->addWidget(m_thumbnail, 0, 0, 1, 2, Qt::AlignLeft); grid->addWidget(m_titleLabel, 1, 0, 1, 2); grid->addWidget(m_avatar, 2, 0, 2, 1, Qt::AlignLeft); grid->addWidget(m_artistLabel, 2, 1, Qt::AlignLeft | Qt::AlignTop); grid->addWidget(m_dateLabel, 3, 1, Qt::AlignLeft | Qt::AlignBottom); grid->addWidget(m_descriptionLabel, 4, 0, 1, 2); grid->setRowStretch(4, 1); grid->setColumnStretch(1, 1); grid->setContentsMargins(0, 0, 0, 0); m_scrollArea->setWidget(scrollWidget); m_scrollArea->setWidgetResizable(true); m_scrollArea->setFixedWidth(330); m_layout = new QHBoxLayout(centralWidget()); m_layout->addWidget(m_scrollArea); m_layout->addWidget(m_view); m_layout->addWidget(m_noTracksLabel); m_layout->setStretch(1, 1); m_layout->setStretch(2, 1); m_layout->setContentsMargins(0, 0, 0, 0); menuBar()->addAction(m_reloadAction); menuBar()->addAction(m_queuePlaylistAction); menuBar()->addAction(m_nowPlayingAction); connect(m_model, SIGNAL(statusChanged(QSoundCloud::ResourcesRequest::Status)), this, SLOT(onModelStatusChanged(QSoundCloud::ResourcesRequest::Status))); connect(m_cache, SIGNAL(imageReady()), this, SLOT(onImageReady())); connect(m_view, SIGNAL(activated(QModelIndex)), this, SLOT(showTrack(QModelIndex))); connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_thumbnail, SIGNAL(clicked()), this, SLOT(playPlaylist())); connect(m_delegate, SIGNAL(thumbnailClicked(QModelIndex)), this, SLOT(playTrack(QModelIndex))); connect(m_reloadAction, SIGNAL(triggered()), m_model, SLOT(reload())); connect(m_queuePlaylistAction, SIGNAL(triggered()), this, SLOT(queuePlaylist())); connect(m_avatar, SIGNAL(clicked()), this, SLOT(showArtist())); connect(m_descriptionLabel, SIGNAL(anchorClicked(QUrl)), this, SLOT(showResource(QUrl))); connect(m_queueAction, SIGNAL(triggered()), this, SLOT(queueTrack())); connect(m_downloadAction, SIGNAL(triggered()), this, SLOT(downloadTrack())); connect(m_shareAction, SIGNAL(triggered()), this, SLOT(shareTrack())); if (!SoundCloud::instance()->userId().isEmpty()) { m_favouriteAction = new QAction(this); m_contextMenu->addAction(m_favouriteAction); connect(m_favouriteAction, SIGNAL(triggered()), this, SLOT(setTrackFavourite())); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { QApplication::setApplicationVersion(VER); // Setup UI ui->setupUi(this); // Configure settings readWindowSettings(); // Setup session session = new Session(this); session->readFromSettings(); connect(session, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); connect(session, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex, int, int))); connect(session, SIGNAL(messageReceived(Server*,Channel*,QString,QStringList,Channel::MessageType)), this, SLOT(handleMessage(Server*,Channel*,QString,QStringList,Channel::MessageType))); connect(session, SIGNAL(serverDisconnected(Server*)), this, SLOT(showDisconnectedMessage(Server*))); // Setup tree view connect(ui->treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(treeItemClicked(const QModelIndex&))); ui->treeView->setModel(session); ui->treeView->setFocusPolicy(Qt::NoFocus); ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(generateContextMenu(const QPoint &))); // Setup sending text connect(ui->sendText, SIGNAL(returnPressed()), this, SLOT(sendMessage())); connect(ui->sendText, SIGNAL(channelCycle(bool)), this, SLOT(cycleChannel(bool))); ui->sendText->setFocus(); // Setup user list ui->userList->setFocusPolicy(Qt::NoFocus); // Setup the main text area document = new QTextDocument(ui->mainText); document->setDefaultStyleSheet(this->readFile(this->mainCssFileName)); ui->mainText->setDocument(document); connect(ui->mainText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); // Set focus on first server QModelIndex modelIndex = session->index(0, 0); this->selectItem(modelIndex); // Setup command parser commandParser = new CommandParser(this); // Setup network manager networkAccessManager = new QNetworkAccessManager(this); connect(networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(imageDownloaded(QNetworkReply*))); updateCheckerNetworkAccessManager = new QNetworkAccessManager(this); connect(updateCheckerNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(versionFileDownloaded(QNetworkReply*))); // Setup web view for checking oembed webView = new QWebView(this); QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, false); QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, false); webView->hide(); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webLoadFinished(bool))); // Let's get some styles up in here QString controlStyles = "QListView, QTreeView, QLineEdit, QPlainTextEdit, QTextBrowser { background:#333;font-family:\"Lucida Console\",Monaco,monospace;font-size:11px;color:#fff; }"; ui->userList->setStyleSheet(controlStyles); ui->treeView->setStyleSheet(controlStyles); ui->mainText->setStyleSheet(controlStyles); ui->sendText->setStyleSheet(controlStyles + "QLineEdit { padding:5px; }, QPlainTextEdit { padding:2px; }"); ui->userList->setAttribute(Qt::WA_MacShowFocusRect, 0); ui->treeView->setAttribute(Qt::WA_MacShowFocusRect, 0); ui->sendText->setAttribute(Qt::WA_MacShowFocusRect, 0); // Setup menu items connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(openPreferences())); connect(ui->actionNewServer, SIGNAL(triggered()), this, SLOT(newServerWindow())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutInfo())); //Check For Updates checkForUpdates(); }
Comments::Comments(QWidget *pParent, const char *name) : QWidget(pParent, name) { _source = Uninitialized; _sourceid = -1; _verboseCommentList = false; if(_x_metrics) _verboseCommentList = _x_metrics->boolean("VerboseCommentList"); QHBoxLayout *main = new QHBoxLayout(this); main->setMargin(0); main->setSpacing(7); QWidget *buttons = new QWidget(this); QVBoxLayout * buttonsLayout = new QVBoxLayout(buttons); buttonsLayout->setMargin(0); buttonsLayout->setSpacing(0); _comment = new XTreeWidget(this); _comment->setObjectName("_comment"); _comment->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); _comment->addColumn(tr("Date/Time"), _timeDateColumn, Qt::AlignCenter,true, "comment_date"); _comment->addColumn(tr("Type"), _itemColumn, Qt::AlignCenter,true, "type"); _comment->addColumn(tr("User"), _userColumn, Qt::AlignCenter,true, "comment_user"); _comment->addColumn(tr("Comment"), -1, Qt::AlignLeft, true, "first"); main->addWidget(_comment); _browser = new QTextBrowser(this); _browser->setObjectName("_browser"); _browser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); _browser->setOpenLinks(false); main->addWidget(_browser); _newComment = new QPushButton(tr("New"), buttons, "_newComment"); buttonsLayout->addWidget(_newComment); _viewComment = new QPushButton(tr("View"), buttons, "_viewComment"); _viewComment->setEnabled(FALSE); buttonsLayout->addWidget(_viewComment); _editComment = new QPushButton(tr("Edit"), buttons, "_editComment"); _editComment->setEnabled(false); buttonsLayout->addWidget(_editComment); QSpacerItem *_buttonSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); buttonsLayout->addItem(_buttonSpacer); buttons->setLayout(buttonsLayout); main->addWidget(buttons); setLayout(main); connect(_newComment, SIGNAL(clicked()), this, SLOT( sNew())); connect(_viewComment, SIGNAL(clicked()), this, SLOT( sView())); connect(_editComment, SIGNAL(clicked()), this, SLOT(sEdit())); connect(_comment, SIGNAL(valid(bool)), this, SLOT(sCheckButtonPriv(bool))); connect(_comment, SIGNAL(itemSelected(int)), _viewComment, SLOT(animateClick())); connect(_browser, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); setFocusProxy(_comment); setVerboseCommentList(_verboseCommentList); }
AddressBook::AddressBook(QWidget *parent) : QMainWindow(parent) { // Init. de la BDD QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("addressbook.sqlite"); if(!db.open()) { // Si l'ouverture du fichier de données est impossible on le notifie à l'utilisateur et on ferme le programme QMessageBox::warning(this, "Init.", "Impossible d'accèder à la base de données.\nImpossible de lancer le programme\n"); exit(1); } // La table contient les données suivantes // id, nom, prénom, date de naissance, sexe, n° téléphone, n° téléphone portable, // n° téléphone professionnel, n° de fax, adresse e-mail, url du site internet, // adresse du domicile, ville du domicile, code postal du domicile // adresse du bureau, ville du bureau, code postal du bureau // l'id du 1er parent et du 2nd parent -- inutilisés mais dans les anciennes contraintes du programmes QSqlQuery query; query.exec("CREATE TABLE IF NOT EXISTS `addressbook` (" "`id` INTEGER PRIMARY KEY," "`lastname` TEXT NOT NULL," "`firstname` TEXT NOT NULL," "`date` TEXT ," "`gender` INTEGER ," "`phone` TEXT ," "`cellphone` TEXT ," "`prophone` TEXT ," "`fax` TEXT ," "`email` TEXT ," "`website` TEXT ," "`homeaddress` TEXT ," "`homecity` TEXT ," "`homezip` INTEGER ," "`proaddress` TEXT ," "`procity` TEXT ," "`prozip` INTEGER ," "`id_parent1` INTEGER ," "`id_parent2` INTEGER )"); // Les éléments du formulaire d'ajout/modification de contact // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREE PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // nameLine = new QLineEdit; nameLine = new QLineEdit; // Champ de saisie du prénom lastnameLine = new QLineEdit; dateLine = new QDateEdit; dateLine->setDisplayFormat("dd/MM/yyyy"); // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREE PAR "LA DOCUMENTATION QT - Line Edits Example" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/widgets-lineedits.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) /* QComboBox *validatorComboBox = new QComboBox; validatorComboBox->addItem(tr("No validator")); validatorComboBox->addItem(tr("Integer validator")); */ sexLine = new QComboBox; // Liste déroulante pour le sexe sexLine->addItem("Masculin"); sexLine->addItem("Féminin"); phoneLine = new QLineEdit; cellphoneLine = new QLineEdit; prophoneLine = new QLineEdit; faxLine = new QLineEdit; emailLine = new QLineEdit; websiteLine = new QLineEdit; // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // addressText = new QTextEdit; homeaddressLine = new QTextEdit; // Boîte de saise de l'adresse perso. homeaddressLine->setFixedHeight(48); // Définition d'une taille fixe pour la boîte de saisie pour ne pas avoir de problème lors du redimensionnement de la fenêtre homecityLine = new QLineEdit; homezipLine = new QLineEdit; proaddressLine = new QTextEdit; proaddressLine->setFixedHeight(48); procityLine = new QLineEdit; prozipLine = new QLineEdit; // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // addButton = new QPushButton(tr("&Add")); addButton = new QPushButton(tr("&Ajouter")); // Bouton pour l'ajout d'une fiche nommé "Ajouter" -- également renommé pour la modification cancelButton = new QPushButton(tr("A&nnuler")); // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part2.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(addButton, SIGNAL(clicked()), this, SLOT(submitContact())); // quand on clique sur addButton on exécute la fonction submitContact() connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // Editeur de données. // Coordonnées pro. // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LA DOCUMENTATION QT - QFormLayout Class Reference" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/qformlayout.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // QFormLayout *formLayout = new QFormLayout; // formLayout->addRow(tr("&Name:"), nameLineEdit); EditorProfessionnalInfos = new QFormLayout; // Création du formulaire EditorProfessionnalInfos EditorProfessionnalInfos->addRow(tr("&Téléphone :"), prophoneLine); // Ajout de la ligne libellée "Téléphone" avec le widget prophoneLine EditorProfessionnalInfos->addRow(tr("&Fax :"), faxLine); EditorProfessionnalInfos->addRow(tr("&Adresse :"), proaddressLine); EditorProfessionnalInfos->addRow(tr("&Code postal :"), prozipLine); EditorProfessionnalInfos->addRow(tr("&Ville :"), procityLine); // Coordonnées perso. EditorPersonnalInfos = new QFormLayout; EditorPersonnalInfos->addRow(tr("&Téléphone :"), phoneLine); EditorPersonnalInfos->addRow(tr("&Portable :"), cellphoneLine); EditorPersonnalInfos->addRow(tr("&Adresse :"), homeaddressLine); EditorPersonnalInfos->addRow(tr("&Code postal :"), homezipLine); EditorPersonnalInfos->addRow(tr("&Ville :"), homecityLine); EditorPersonnalInfos->addRow(tr("&E-mail :"), emailLine); EditorPersonnalInfos->addRow(tr("&Site web :"), websiteLine); // Etat civil. EditorIdentity = new QFormLayout; EditorIdentity->addRow(tr("&Prénom :"), nameLine); EditorIdentity->addRow(tr("&Nom :"), lastnameLine); EditorIdentity->addRow(tr("&Sexe :"), sexLine); EditorIdentity->addRow(tr("&Date de naissance :"), dateLine); // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE SITE DU ZERO - Apprenez à programmer en C++ ! > [Pratique] Créez vos propres fenêtres avec Qt > Les principaux widgets" (disponible à l'adresse "http://www.siteduzero.com/tutoriel-3-11316-les-principaux-widgets.html#ss_part_5"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) /* QFrame *frame = new QFrame(&fenetre); frame->setFrameShape(QFrame::StyledPanel); frame->setGeometry(30, 20, 120, 90); QLineEdit *lineEdit = new QLineEdit("Entrez votre nom"); QPushButton *bouton1 = new QPushButton("Cliquez ici"); QPushButton *bouton2 = new QPushButton("Ou là..."); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(lineEdit); vbox->addWidget(bouton1); vbox->addWidget(bouton2); frame->setLayout(vbox); */ Editor = new QTabWidget(); // Création du widget à onglets Editor Editor->setGeometry(30, 20, 240, 160); // définition de la position 30,20 et de la taille 240*160 page1 = new QWidget; // Création du widget page1 - 1er onglet page1->setLayout(EditorIdentity); // Définition du contenu de page1 Editor->addTab(page1, "Identité"); // Ajout et définition du titre du 3ème onglet : "Identité" page2 = new QWidget; page2->setLayout(EditorPersonnalInfos); Editor->addTab(page2, "Coordonnées perso."); page3 = new QWidget; page3->setLayout(EditorProfessionnalInfos); Editor->addTab(page3, "Coordonnées pro."); ActionsButtons = new QHBoxLayout; // Création d'un layout horizontal pour les boutons ActionsButtons->addWidget(addButton); // Ajout du bouton addButton au layout ActionsButtons->addWidget(cancelButton); ActionsButtonsWidget = new QWidget; // Création d'un widget pour les boutons ActionsButtonsWidget->setLayout(ActionsButtons); // Définition du layout ActionsButtons au widget ActionsButtonsWidget dockLayout = new QVBoxLayout; // Création d'un layout vertical pour le dock dockLayout->addWidget(Editor); dockLayout->addWidget(ActionsButtonsWidget); DockWidget = new QWidget; // Création d'un widget pour le dock DockWidget->setLayout(dockLayout); // Définition du layout dockLayout au widget DockWidget dockInfos = new QDockWidget(tr("Informations"), this); // Création d'un widget dock de titre "Informations" addDockWidget(Qt::LeftDockWidgetArea, dockInfos); // Ajout du dock dockInfos à la gauche de la fenêtre infosLabel = new QTextBrowser(this); // Création d'un nouveau widget QTextBrowser infoLabel infosLabel->setText("<h1>Bienvenue !</h1><p>Sélectionnez un contact pour en afficher les détails ou ajoutez une nouvelle fiche au carnet d'adresses.</p>"); // Définition du contenu du QTextBrowser. Il autorise le formatage du texte avec du HTML infosLabel->setAlignment(Qt::AlignTop); // Définition de l'alignement vertical du texte : haut infosLabel->setReadOnly(1); // Définition du widget en lecture seule : il est utilisé uniquement pour l'affichage infosLabel->setOpenExternalLinks(1); // Autoriser l'ouverture des liens externes dans un navigateur infosLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); // Autoriser les liens et la sélection de texte à la souris connect(infosLabel, SIGNAL(anchorClicked(QUrl)), this, SLOT(inContextLink(QUrl))); // signal pour l'ouverture des liens internes (ancres #blabla) dockInfos->setWidget(infosLabel); dock = new QDockWidget(tr("Editeur"), this); dock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea | Qt::LeftDockWidgetArea); dock->setWidget(DockWidget); addDockWidget(Qt::RightDockWidgetArea, dock); // Modèle. Objet désignant la table "addressbook" de la BDD. // Couche d'abstraction destinée à faciliter les accès, éviter les injections etc. model = new QSqlTableModel; model->setTable("addressbook"); // définition de la table traitée model->setEditStrategy(QSqlTableModel::OnManualSubmit); // stratégie d'édition du modèle (= quand on enregistre le fichier ?) - réglé sur un déclenchement manuel model->select(); // mise à jour des données (on selectionne tout) model->setHeaderData(0, Qt::Horizontal, tr("id")); // modification du titre de la colonne 0 model->setHeaderData(1, Qt::Horizontal, tr("Prénom")); model->setHeaderData(2, Qt::Horizontal, tr("Nom")); // Vue. Objet affichant le modèle // Widget proposé simplifiant les communications avec le modèle. view = new QTableView; view->setModel(model); // Définition du modèle sur model switchView(); // Appel de la fonction switchView de la classe. Elle retire la majeure partie des colonnes pour n'afficher que l'id, le nom et le prénom view->setShowGrid(0); // Ote la grille view->setEditTriggers(QAbstractItemView::NoEditTriggers); // Désactivation de l'édition au sein du tableau view->setSelectionBehavior(QAbstractItemView::SelectRows); // Permet la seule sélection d'une ligne view->setSelectionMode(QAbstractItemView::SingleSelection); // Permettre la sélection d'une seule ligne seulement view->sortByColumn(0,Qt::AscendingOrder); // Tri initial par id view->verticalHeader()->hide(); // Cache l'affichage des numéros de ligne view->setSortingEnabled(true); // Autorise le tri view->show(); // Affichage du tableau connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(retrieveContactData())); setCentralWidget(view); // défini view en tant que widget central de la fenêtre (celle de la classe) // Affichage de la barre de menu. menuFile = menuBar()->addMenu("&Fichier"); // Nouvelle barre de menu : Fichier menuitemNew = menuFile->addAction("&Nouvelle fiche"); // Nouvel élément de menu : Nouvelle fiche menuitemNew->setShortcut(QKeySequence::New); // Définition du raccourci clavier assigné à cette entrée du menu menuitemNew->setIcon(QIcon("./icons/list-add.png")); // Définition de l'icône associée à cette entrée du menu connect(menuitemNew, SIGNAL(triggered()), this, SLOT(editorClear())); menuitemDelete = menuFile->addAction("&Supprimer fiche"); menuitemDelete->setShortcut(QKeySequence::Delete); menuitemDelete->setIcon(QIcon("./icons/list-remove.png")); connect(menuitemDelete, SIGNAL(triggered()), this, SLOT(deleteContact())); menuitemExport = menuFile->addAction("&Exporter"); connect(menuitemExport, SIGNAL(triggered()), this, SLOT(csvExport())); menuitemQuit = menuFile->addAction("&Quitter"); menuitemQuit->setShortcut(QKeySequence::Quit); connect(menuitemQuit, SIGNAL(triggered()), qApp, SLOT(quit())); /* menuView = menuBar()->addMenu("&Affichage"); menuitemFullView = menuView->addAction("&Affichage complet"); menuitemFullView->setCheckable(true); connect(menuitemFullView, SIGNAL(triggered()), this, SLOT(switchView()));*/ menuHelp = menuBar()->addMenu("&Aide"); menuitemAboutapp = menuHelp->addAction("&A propos..."); connect(menuitemAboutapp, SIGNAL(triggered()), this, SLOT(aboutApp())); menuitemAboutQt = menuHelp->addAction("&A propos de Qt..."); connect(menuitemAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt())); // Affichage de la barre d'outils QToolBar *toolbar = addToolBar("Barre d'outils"); // Nouvelle barre d'outils toolbar->addAction(menuitemNew); // ajout du bouton menuitemNew à la barre (même élément que celui du menu) toolbar->addAction(menuitemDelete); quicksearchLabel = new QLabel(tr("Recherche : "),this); toolbar->addWidget(quicksearchLabel); // ajout champ de recherche quicksearchLine = new QLineEdit; toolbar->addWidget(quicksearchLine); connect(quicksearchLine, SIGNAL(textChanged(QString)), this, SLOT(updateSearch(QString))); // TODO : Trouver un titre pour cette application. setWindowTitle(tr("Swithom")); }
ServerChoice::ServerChoice(TeamHolder* team) : ui(new Ui::ServerChoice), wasConnected(false), team(team) { ui->setupUi(this); ui->announcement->hide(); ServerChoiceModel *model = new ServerChoiceModel(); model->setParent(ui->serverList); filter = new QSortFilterProxyModel(ui->serverList); filter->setSourceModel(model); filter->setSortRole(ServerChoiceModel::SortRole); ui->serverList->setModel(filter); connect(ui->description, SIGNAL(anchorClicked(QUrl)), SLOT(anchorClicked(QUrl))); QSettings settings; registry_connection = new Analyzer(true); connect(registry_connection, SIGNAL(connected()), SLOT(connected())); registry_connection->connectTo( settings.value("ServerChoice/RegistryServer", "registry.pokemon-online.eu").toString(), settings.value("ServerChoice/RegistryPort", 5090).toUInt() ); registry_connection->setParent(this); ui->switchPort->setIcon(QApplication::style()->standardIcon(QStyle::SP_BrowserReload)); connect(registry_connection, SIGNAL(connectionError(int,QString)), SLOT(connectionError(int , QString))); connect(registry_connection, SIGNAL(regAnnouncementReceived(QString)), ui->announcement, SLOT(setText(QString))); connect(registry_connection, SIGNAL(regAnnouncementReceived(QString)), ui->announcement, SLOT(show())); connect(registry_connection, SIGNAL(serverReceived(ServerInfo)), model, SLOT(addServer(ServerInfo))); connect(this, SIGNAL(clearList()), model, SLOT(clear())); connect(registry_connection, SIGNAL(serverReceived(ServerInfo)), SLOT(serverAdded())); //TO-DO: Make the item 0 un-resizable and unselectable - Latios ui->serverList->setColumnWidth(0, settings.value("ServerChoice/PasswordProtectedWidth", 26).toInt()); ui->serverList->setColumnWidth(1, settings.value("ServerChoice/ServerNameWidth", 152).toInt()); if (settings.contains("ServerChoice/PlayersInfoWidth")) { ui->serverList->setColumnWidth(2, settings.value("ServerChoice/PlayersInfoWidth").toInt()); } ui->serverList->horizontalHeader()->setStretchLastSection(true); connect(ui->serverList, SIGNAL(activated(QModelIndex)), SLOT(regServerChosen(QModelIndex))); connect(ui->serverList, SIGNAL(currentCellChanged(QModelIndex)), SLOT(showDetails(QModelIndex))); ui->nameEdit->setText(team->name()); ui->advServerEdit->addItem(settings.value("ServerChoice/DefaultServer").toString()); connect(ui->nameEdit, SIGNAL(returnPressed()), SLOT(advServerChosen())); connect(ui->advServerEdit->lineEdit(), SIGNAL(returnPressed()), SLOT(advServerChosen())); QCompleter *completer = new QCompleter(ui->advServerEdit); completer->setCaseSensitivity(Qt::CaseInsensitive); QStringList res = settings.value("ServerChoice/SavedServers").toStringList(); foreach (QString r, res) { if (r.contains("-")) { savedServers.push_back(QStringList() << r.section("-", -1).trimmed() << r.section("-", 0, -2).trimmed()); } else { savedServers.push_back(QStringList() << r << ""); } } QStringListModel *m = new QStringListModel(res, completer); completer->setModel(m); ui->advServerEdit->setCompleter(completer); ui->advServerEdit->setModel(m); connect(ui->teambuilder, SIGNAL(clicked()), SIGNAL(teambuilder())); connect(ui->advancedConnection, SIGNAL(clicked()), SLOT(advServerChosen())); QTimer *t = new QTimer(this); t->singleShot(5000, this, SLOT(timeout())); #if QT_VERSION >= QT_VERSION_CHECK(4,8,0) ui->serverList->sortByColumn(ServerChoiceModel::Players, Qt::SortOrder(filter->headerData(ServerChoiceModel::Players, Qt::Horizontal, Qt::InitialSortOrderRole).toInt())); #else ui->serverList->sortByColumn(ServerChoiceModel::Players, Qt::DescendingOrder); #endif }