void AttachmentsSaveToWorker::work() { Util::LibraryLogger::setCurrentThreadName("AttSaveToW"); try { { auto session = Db::makeSession(sessionConfig_); SmartSqlite::ScopedTransaction tx(session); auto isDraft = isDraft_ ? Dao::IsDraft::Yes : Dao::IsDraft::No; auto dao = Dao::AttachmentDao::load( isDraft, convOrMsgId_, attId_, session); if (dao) { auto stream = Util::Filesystem::makeOfstream(path_); dao->saveContent(*stream); } tx.commit(); } notifyListener(convOrMsgId_, attId_, path_); } catch(std::exception &ex) { Log.e() << "AttachmentsSaveToWorker failed for path '" << path_ << "' with message:\n" << Util::formatException(ex); error(convOrMsgId_, attId_, path_, toLocalError(std::current_exception())); } }
void MainWindow::onSaveActivated() { if (openedFilePath.isEmpty()) onSaveAsActivated(); if (saveContent(openedFilePath)) emit modelSaved(); }
void MainWindow::onSaveAsActivated() { QString path = QFileDialog::getSaveFileName(this, Editor::Strings::SaveFileDialog, QString(), Editor::Strings::ContentFiles); if (saveContent(path)){ emit modelSaved(); openedFilePath = path; } }
changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t) : QDialog(parent), myConfig(config), myType(t) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif setupUi(this); this->installEventFilter(this); switch (myType) { case CHANGE_HUMAN_PLAYER_NAME: { label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one.")); label_lineLabel->setText(tr("Nick name:")); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); lineEdit->setMaxLength(12); checkBox->hide(); this->setGeometry(this->x(), this->y(), this->width(), this->height()-20 ); } break; case CHANGE_NICK_ALREADY_IN_USE: { label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name.")); label_lineLabel->setText(tr("Nick name:")); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); lineEdit->setMaxLength(12); } break; case CHANGE_NICK_INVALID: { label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one.")); label_lineLabel->setText(tr("Nick name:")); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); lineEdit->setMaxLength(12); } break; case CHANGE_INET_GAME_NAME_IN_USE: { label_Message->setText(tr("There is already a game with your chosen game name.\nPlease choose another one!")); label_lineLabel->setText(tr("Game name:")); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); lineEdit->setMaxLength(48); } break; case CHANGE_INET_BAD_GAME_NAME: { label_Message->setText(tr("There is a forbidden word in your chosen game name.\nPlease choose another one!")); label_lineLabel->setText(tr("Game name:")); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); lineEdit->setMaxLength(48); } break; } connect(this, SIGNAL(accepted ()), this, SLOT(saveContent())); }
void OOoReportBuilder::parse(bool show) { if (!m_isLoaded) { return; } parseDocument(); saveContent(); saveReport(); if (show) showReport(); }
Editor::Editor(QWidget *parent) : QPlainTextEdit(parent) { propDialog = ((MainWindow *) parent)->propDialog; ctrlPressed = false; isSpin = false; expectAutoComplete = false; canUndo = false; canRedo = false; canCopy = false; lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth())); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); updateLineNumberAreaWidth(); highlighter = 0; setHighlights(); setMouseTracking(true); setCenterOnScroll(true); setWordWrapMode(QTextOption::NoWrap); currentTheme = &Singleton<ColorScheme>::Instance(); updateColors(); updateFonts(); saveContent(); connect(this,SIGNAL(cursorPositionChanged()),this,SLOT(updateBackgroundColors())); connect(propDialog,SIGNAL(updateColors()),this,SLOT(updateColors())); connect(propDialog,SIGNAL(updateFonts()),this,SLOT(updateFonts())); connect(propDialog->getTabSpaceLedit(),SIGNAL(textChanged(QString)), this, SLOT(tabSpacesChanged())); connect(this,SIGNAL(undoAvailable(bool)), this, SLOT(setUndo(bool))); connect(this,SIGNAL(redoAvailable(bool)), this, SLOT(setRedo(bool))); connect(this,SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool))); // this must be a pointer otherwise we can't control the position. cbAuto = new QComboBox(this); cbAuto->hide(); }
EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent) { highlighter = 0; setExtension("spin"); canUndo = false; canRedo = false; canCopy = false; tabOn = false; currentTheme = &Singleton<ColorScheme>::Instance(); loadPreferences(); lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth())); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); updateLineNumberAreaWidth(); setMouseTracking(true); setCenterOnScroll(true); setWordWrapMode(QTextOption::NoWrap); updateColors(); updateFonts(); saveContent(); connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(setUndo(bool))); connect(this, SIGNAL(redoAvailable(bool)), this, SLOT(setRedo(bool))); connect(this, SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool))); // this must be a pointer otherwise we can't control the position. cbAuto = new QComboBox(this); cbAuto->setMaxVisibleItems(10); cbAuto->hide(); }
void CFrmSettings::okSlot() { saveContent(); this->done(drawGraph()); }
MessageOutput::MessageOutput(QWidget *parent, const char *name ) : QListBox(parent,name) { m_maxItems = 2000; QPalette pal = palette(); pal.setColor(QColorGroup::HighlightedText, pal.color(QPalette::Normal, QColorGroup::Text)); pal.setColor(QColorGroup::Highlight, pal.color(QPalette::Normal, QColorGroup::Mid)); setPalette(pal); setFocusPolicy( NoFocus ); m_popupMenu = new KPopupMenu(this); connect(this, SIGNAL(contextMenuRequested(QListBoxItem*, const QPoint&)), this, SLOT(showMenu(QListBoxItem*, const QPoint&))); m_popupMenu->insertItem( SmallIconSet("editcopy"), i18n("&Copy"), this, SLOT(copyContent()) ) ; m_popupMenu->insertItem( SmallIconSet("filesaveas"), i18n("&Save As..."), this, SLOT(saveContent()) ) ; m_popupMenu->insertSeparator(); m_popupMenu->insertItem( SmallIconSet("editclear"), i18n("Clear"), this, SLOT(clear()) ) ; connect( this, SIGNAL(clicked(QListBoxItem*)), SLOT(clickItem(QListBoxItem*)) ); }
RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); toolbar = new QToolBar; setupActions(); layout->addWidget(toolbar); fontToolbar = new QToolBar; setupFontActions(); layout->addWidget(fontToolbar); textedit = new QTextEdit; textedit->setTabStopWidth(40); layout->addWidget(textedit); findWidget = new TextFind(this); findWidget->hide(); layout->addWidget(findWidget); setLayout(layout); // find connect(actionFind, SIGNAL(triggered()), findWidget, SLOT(show())); connect(findWidget->getNextBtn(), SIGNAL(clicked()), this, SLOT(findNext())); connect(findWidget->getPrevBtn(), SIGNAL(clicked()), this, SLOT(findPrev())); connect(findWidget->getFindEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(findFirst())); // save connect(actionSave, SIGNAL(triggered()), this, SLOT(saveContent())); // alignment alignmentChanged(textedit->alignment()); connect(textedit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); // color & font connect(textedit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); colorChanged(textedit->textColor()); fontChanged(textedit->font()); // undo & redo connect(textedit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textedit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textedit->document()->isModified()); actionUndo->setEnabled(textedit->document()->isUndoAvailable()); actionRedo->setEnabled(textedit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textedit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textedit, SLOT(redo())); // cut, copy, paste actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textedit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textedit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textedit, SLOT(paste())); connect(textedit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textedit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); }