CQIllustratorAlignToolbar * CQIllustratorAlignMode:: createToolbar() { toolbar_ = new CQIllustratorAlignToolbar(this); connect(toolbar_, SIGNAL(alignLeft()), this, SLOT(alignLSlot())); connect(toolbar_, SIGNAL(alignLeftPreview()), this, SLOT(alignLPreviewSlot())); connect(toolbar_, SIGNAL(alignBottom()), this, SLOT(alignBSlot())); connect(toolbar_, SIGNAL(alignBottomPreview()), this, SLOT(alignBPreviewSlot())); connect(toolbar_, SIGNAL(alignRight()), this, SLOT(alignRSlot())); connect(toolbar_, SIGNAL(alignRightPreview()), this, SLOT(alignRPreviewSlot())); connect(toolbar_, SIGNAL(alignTop()), this, SLOT(alignTSlot())); connect(toolbar_, SIGNAL(alignTopPreview()), this, SLOT(alignTPreviewSlot())); connect(toolbar_, SIGNAL(alignHorizontal()), this, SLOT(alignHSlot())); connect(toolbar_, SIGNAL(alignHorizontalPreview()), this, SLOT(alignHPreviewSlot())); connect(toolbar_, SIGNAL(alignVertical()), this, SLOT(alignVSlot())); connect(toolbar_, SIGNAL(alignVerticalPreview()), this, SLOT(alignVPreviewSlot())); connect(toolbar_, SIGNAL(alignPreviewClear()), this, SLOT(alignPreviewClearSlot())); connect(toolbar_, SIGNAL(selectAnchorObject()), illustrator_, SLOT(anchorObjectSlot())); connect(toolbar_, SIGNAL(selectAnchorPosition()), illustrator_, SLOT(anchorPositionSlot())); connect(toolbar_, SIGNAL(cancelSelectAnchor()), illustrator_, SLOT(cancelAnchorSlot())); return toolbar_; }
void PixelRegion::align(Side side, int pos) { switch (side) { case LEFT: alignLeft(pos); break; case TOP: alignTop(pos); break; case RIGHT: alignRight(pos); break; case BOTTOM: alignBottom(pos); break; } }
CQAlignButtons:: CQAlignButtons() : QWidget(0) { QGridLayout *agrid = new QGridLayout(this); agrid->setMargin(0); agrid->setSpacing(8); CQToolButton *alignl = new CQToolButton(CQPixmapCacheInst->getIcon("ALIGN_TO_LEFT")); CQToolButton *alignb = new CQToolButton(CQPixmapCacheInst->getIcon("ALIGN_TO_BOTTOM")); CQToolButton *alignr = new CQToolButton(CQPixmapCacheInst->getIcon("ALIGN_TO_RIGHT")); CQToolButton *alignt = new CQToolButton(CQPixmapCacheInst->getIcon("ALIGN_TO_TOP")); CQToolButton *alignhc = new CQToolButton(CQPixmapCacheInst->getIcon("ALIGN_HORIZONTALLY")); CQToolButton *alignvc = new CQToolButton(CQPixmapCacheInst->getIcon("ALIGN_VERTICALLY")); alignl ->setToolTip("Align Left"); alignb ->setToolTip("Align Bottom"); alignr ->setToolTip("Align Right"); alignt ->setToolTip("Align Top"); alignhc->setToolTip("Align Horizontal Center"); alignvc->setToolTip("Align Vertical Center"); agrid->addWidget(alignl , 0, 0); agrid->addWidget(alignb , 0, 1); agrid->addWidget(alignr , 0, 2); agrid->addWidget(alignt , 0, 3); agrid->addWidget(alignhc, 0, 4); agrid->addWidget(alignvc, 0, 5); agrid->setColumnStretch(6, 1); connect(alignl , SIGNAL(clicked()), this, SIGNAL(alignLeft())); connect(alignb , SIGNAL(clicked()), this, SIGNAL(alignBottom())); connect(alignr , SIGNAL(clicked()), this, SIGNAL(alignRight())); connect(alignt , SIGNAL(clicked()), this, SIGNAL(alignTop())); connect(alignhc, SIGNAL(clicked()), this, SIGNAL(alignHorizontal())); connect(alignvc, SIGNAL(clicked()), this, SIGNAL(alignVertical())); connect(alignl , SIGNAL(previewStart()), this, SIGNAL(alignLeftPreview())); connect(alignb , SIGNAL(previewStart()), this, SIGNAL(alignBottomPreview())); connect(alignr , SIGNAL(previewStart()), this, SIGNAL(alignRightPreview())); connect(alignt , SIGNAL(previewStart()), this, SIGNAL(alignTopPreview())); connect(alignhc, SIGNAL(previewStart()), this, SIGNAL(alignHorizontalPreview())); connect(alignvc, SIGNAL(previewStart()), this, SIGNAL(alignVerticalPreview())); connect(alignl , SIGNAL(previewStop()), this, SIGNAL(alignPreviewClear())); connect(alignb , SIGNAL(previewStop()), this, SIGNAL(alignPreviewClear())); connect(alignr , SIGNAL(previewStop()), this, SIGNAL(alignPreviewClear())); connect(alignt , SIGNAL(previewStop()), this, SIGNAL(alignPreviewClear())); connect(alignhc, SIGNAL(previewStop()), this, SIGNAL(alignPreviewClear())); connect(alignvc, SIGNAL(previewStop()), this, SIGNAL(alignPreviewClear())); }
void CQIllustratorAlignToolbar:: addWidgets() { QBoxLayout *layout = qobject_cast<QBoxLayout *>(CQIllustratorToolbar::layout()); QGridLayout *grid = new QGridLayout; grid->setMargin(0); grid->setSpacing(2); layout->addLayout(grid); //----- QTabWidget *tab = new QTabWidget; QFont font = tab->font(); font.setPointSizeF(font.pointSizeF()*0.7); tab->setFont(font); //------ alignw_ = new CQAlignButtons; tab->addTab(alignw_, "Align"); connect(alignw_, SIGNAL(alignLeft()), this, SIGNAL(alignLeft())); connect(alignw_, SIGNAL(alignBottom()), this, SIGNAL(alignBottom())); connect(alignw_, SIGNAL(alignRight()), this, SIGNAL(alignRight())); connect(alignw_, SIGNAL(alignTop()), this, SIGNAL(alignTop())); connect(alignw_, SIGNAL(alignHorizontal()), this, SIGNAL(alignHorizontal())); connect(alignw_, SIGNAL(alignVertical()), this, SIGNAL(alignVertical())); connect(alignw_, SIGNAL(alignLeftPreview()), this, SIGNAL(alignLeftPreview())); connect(alignw_, SIGNAL(alignBottomPreview()), this, SIGNAL(alignBottomPreview())); connect(alignw_, SIGNAL(alignRightPreview()), this, SIGNAL(alignRightPreview())); connect(alignw_, SIGNAL(alignTopPreview()), this, SIGNAL(alignTopPreview())); connect(alignw_, SIGNAL(alignHorizontalPreview()), this, SIGNAL(alignHorizontalPreview())); connect(alignw_, SIGNAL(alignVerticalPreview()), this, SIGNAL(alignVerticalPreview())); connect(alignw_, SIGNAL(alignPreviewClear()), this, SIGNAL(alignPreviewClear())); //------ distw_ = new CQDistButtons; tab->addTab(distw_, "Distribute"); //------ spreadw_ = new CQSpreadButtons; tab->addTab(spreadw_, "Spread"); //------ grid->addWidget(tab, 0, 0, 2, 1); //------ QLabel *olabel = new QLabel("<small><b>Offset</b></small>"); offset_ = new CQRealEdit(0.0); offset_->setFocusPolicy(Qt::ClickFocus); grid->addWidget(olabel , 0, 1); grid->addWidget(offset_, 1, 1); //------ anchor_ = new CQAlignAnchor; connect(anchor_, SIGNAL(selectObject()), this, SIGNAL(selectAnchorObject())); connect(anchor_, SIGNAL(selectPosition()), this, SIGNAL(selectAnchorPosition())); connect(anchor_, SIGNAL(cancelSelect()), this, SIGNAL(cancelSelectAnchor())); grid->addWidget(anchor_, 0, 2, 2, 1); //------ grid->setColumnStretch(3, 1); }
void TextEditor::addAlignmentActions(QMenu * menu) { if(document()->isEmpty()) return; QMenu * align_menu = menu->addMenu(tr("Alignment")); QAction * align_left = align_menu->addAction(iconFromTheme("format-justify-left"), tr("Left"), this, SLOT(alignLeft())); QAction * align_right = align_menu->addAction(iconFromTheme("format-justify-right"), tr("Right"), this, SLOT(alignRight())); QAction * align_center = align_menu->addAction(iconFromTheme("format-justify-center"), tr("Center"), this, SLOT(alignCenter())); QAction * align_justify = align_menu->addAction(iconFromTheme("format-justify-fill"), tr("Justify"), this, SLOT(alignJustify())); switch(textCursor().blockFormat().alignment()) { case Qt::AlignLeft: align_left->setCheckable(true); align_left->setChecked(true); break; case Qt::AlignRight: align_right->setCheckable(true); align_right->setChecked(true); break; case Qt::AlignHCenter: align_center->setCheckable(true); align_center->setChecked(true); break; case Qt::AlignJustify: align_justify->setCheckable(true); align_justify->setChecked(true); break; default: break; } }
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); }
int main(void) { initTMR(); initSensor(); initMotor(); TRISButton = OUTPUT; WEAKASSPULLUP = ENABLED; TRISLEDR = OUTPUT; TRISLEDF = OUTPUT; TRISLEDL = OUTPUT; while (1) { switch (state) { case idle: stop(); if (button == PRESSED) state = debouncePress; nextState = follow; break; case wait: if (button == UNPRESSED) state = debounceRelease; break; case debouncePress: delayUs(5000); state = wait; break; case debounceRelease: delayUs(5000); state = nextState; break; case follow: nextState = idle; //delayUs(5000); if (IFS0bits.AD1IF == 1) { IFS0bits.AD1IF = 0; front = getSensorFront(); left = getSensorLeft(); right = getSensorRight(); } if ((right == ONTAPE || left == ONTAPE)) { stop(); if (left == ONTAPE && front == OFFTAPE) alignLeft(); else if (right == ONTAPE && front == OFFTAPE) alignRight(); else if(right == ONTAPE && front == ONTAPE && left == ONTAPE) flip(); else forward(); } else if (front == ONTAPE) { forward(); } /*else if(front == ONTAPE && (right == ONTAPE || left == ONTAPE)) { stop(); if(turns < 3) turnRight(); else if (turns == 3) flip(); else turnLeft(); turns++; }*/ if (button == PRESSED) state = debouncePress; break; } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); ui->menuFile->insertAction(ui->actionExit, recentFileActions[i]); } recentFilesSeparator = ui->menuFile->insertSeparator(ui->actionExit); form = new Form(this); view = new GraphicsView(form, this); setCentralWidget(view); itemWidget = new ItemWidget(ui->propertyWidget); itemWidget->setHidden(true); connect(view, SIGNAL(mouseDoubleClick()), itemWidget, SLOT(selectPicture())); formWidget = new FormWidget(ui->propertyWidget); formWidget->connectForm(form); formWidget->update(form); ui->propertyWidget->setWidget(formWidget); fontCombo = new QFontComboBox(this); ui->formatToolBar->insertWidget(ui->actionBold, fontCombo); insertGroup = new QActionGroup(this); insertGroup->addAction(ui->actionSelect); insertGroup->addAction(ui->actionPaint); connect(insertGroup, SIGNAL(triggered(QAction*)), this, SLOT(insertObject(QAction*))); ui->actionLeft->setData(Qt::AlignLeft); ui->actionCenter->setData(Qt::AlignHCenter); ui->actionRight->setData(Qt::AlignRight); zoomGroup = new QActionGroup(this); zoomGroup->addAction(ui->actionActualSize); zoomGroup->addAction(ui->actionFitWidth); zoomGroup->addAction(ui->actionFitHeight); connect(zoomGroup, SIGNAL(triggered(QAction*)), this, SLOT(zoom(QAction*))); ui->actionActualSize->setData(GraphicsView::ActualSize); ui->actionFitWidth->setData(GraphicsView::FitWidth); ui->actionFitHeight->setData(GraphicsView::FitHeight); horzAlignGroup = new QActionGroup(this); horzAlignGroup->addAction(ui->actionLeft); horzAlignGroup->addAction(ui->actionCenter); horzAlignGroup->addAction(ui->actionRight); connect(horzAlignGroup, SIGNAL(triggered(QAction*)), this, SLOT(horzAlign(QAction*))); sizeGroup = new QActionGroup(this); sizeGroup->addAction(ui->actionShrinkWidth); sizeGroup->addAction(ui->actionGrowWidth); sizeGroup->addAction(ui->actionPageWidth); sizeGroup->addAction(ui->actionShrinkHeight); sizeGroup->addAction(ui->actionGrowHeight); sizeGroup->addAction(ui->actionPageHeight); sizeGroup->addAction(ui->actionShrinkBoth); sizeGroup->addAction(ui->actionGrowBoth); sizeGroup->addAction(ui->actionPageBoth); ui->actionShrinkWidth->setData(Form::ShrinkWidth); ui->actionGrowWidth->setData(Form::GrowWidth); ui->actionPageWidth->setData(Form::PageWidth); ui->actionShrinkHeight->setData(Form::ShrinkHeight); ui->actionGrowHeight->setData(Form::GrowHeight); ui->actionPageHeight->setData(Form::PageHeight); ui->actionShrinkBoth->setData(Form::ShrinkBoth); ui->actionGrowBoth->setData(Form::GrowBoth); ui->actionPageBoth->setData(Form::PageBoth); connect(sizeGroup, SIGNAL(triggered(QAction*)), this, SLOT(size(QAction*))); connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newForm())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openForm())); connect(ui->actionReload, SIGNAL(triggered()), this, SLOT(reload())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveForm())); connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveFormAs())); connect(ui->actionSaveAsPDF, SIGNAL(triggered()), this, SLOT(saveFormAsPdf())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui->actionOpenPrintData, SIGNAL(triggered()), this, SLOT(openPrintData())); connect(ui->actionPageSetup, SIGNAL(triggered()), form, SLOT(pageSetup())); connect(ui->actionPagePreview, SIGNAL(triggered()), this, SLOT(preview())); connect(ui->actionSend, SIGNAL(triggered()), this, SLOT(email())); connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print())); connect(ui->actionFullScreen, SIGNAL(triggered()), this, SLOT(fullScreen())); connect(ui->actionMargins, SIGNAL(toggled(bool)), form, SLOT(showMargins(bool))); connect(ui->actionGrid, SIGNAL(toggled(bool)), form, SLOT(showGrid(bool))); connect(ui->actionPrintData, SIGNAL(toggled(bool)), form, SLOT(showData(bool))); connect(ui->actionSelectAll, SIGNAL(triggered()), form, SLOT(selectAll())); connect(ui->actionDelete, SIGNAL(triggered()), form, SLOT(deleteSelected())); connect(ui->actionProperties, SIGNAL(toggled(bool)), ui->propertyWidget, SLOT(setVisible(bool))); connect(ui->actionMoveForwards, SIGNAL(triggered()), form, SLOT(moveForwards())); connect(ui->actionMoveBackwards, SIGNAL(triggered()), form, SLOT(moveBackwards())); connect(ui->actionAlignLeft, SIGNAL(triggered()), form, SLOT(alignLeft())); connect(ui->actionAlignRight, SIGNAL(triggered()), form, SLOT(alignRight())); connect(ui->actionAlignTop, SIGNAL(triggered()), form, SLOT(alignTop())); connect(ui->actionAlignBottom, SIGNAL(triggered()), form, SLOT(alignBottom())); connect(ui->actionCut, SIGNAL(triggered()), form, SLOT(cut())); connect(ui->actionCopy, SIGNAL(triggered()), form, SLOT(copy())); connect(ui->actionPaste, SIGNAL(triggered()), this, SLOT(paste())); connect(ui->actionFirstPage, SIGNAL(triggered()), this, SLOT(firstPage())); connect(ui->actionPreviousPage, SIGNAL(triggered()), this, SLOT(previousPage())); connect(ui->actionNextPage, SIGNAL(triggered()), this, SLOT(nextPage())); connect(ui->actionLastPage, SIGNAL(triggered()), this, SLOT(lastPage())); connect(ui->menuView, SIGNAL(aboutToShow()), this, SLOT(updateViewMenu())); connect(form, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); connect(form, SIGNAL(changed()), this, SLOT(formChanged())); connect(view, SIGNAL(doneRubberBanding(QRectF)), this, SLOT(doneRubberBanding(QRectF))); connectForm(); loadSettings(); QTimer::singleShot(0, this, SLOT(init())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // open database connection db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite"); if(!db.open()) { qDebug() << db.lastError(); qFatal("Failed to connect."); } // setup UI ui->setupUi(this); ui->toolBar->addWidget(ui->comboFonts); ui->toolBar->addWidget(ui->comboFontSizes); ui->toolBar->addWidget(ui->comboColors); // set text editor defaults ui->textNote->document()->setIndentWidth(20); ui->textNote->setTabStopWidth(20); ui->textNote->setTabChangesFocus(false); ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab); ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab); // setup comboColors QPixmap pix(16, 16); pix.fill(Qt::white); ui->comboColors->addItem(pix, ""); pix.fill(Qt::black); ui->comboColors->addItem(pix, ""); pix.fill(Qt::red); ui->comboColors->addItem(pix, ""); pix.fill(Qt::blue); ui->comboColors->addItem(pix, ""); pix.fill(Qt::darkGreen); ui->comboColors->addItem(pix, ""); pix.fill(Qt::gray); ui->comboColors->addItem(pix, ""); // create system tray icon createActions(); createTrayIcon(); // create models categoriesModel = new QSqlTableModel(); categoriesModel->setTable("categories"); categoriesModel->setSort(1, Qt::AscendingOrder); categoriesModel->select(); ui->listCategories->setModel(categoriesModel); ui->listCategories->setModelColumn(1); notesModel = new QSqlTableModel(); notesModel->setTable("notes"); ui->listNotes->setModel(notesModel); ui->listNotes->setModelColumn(2); // set splitter size QList<int> sizes; sizes << 230 << 150; ui->splitterLists->setSizes(sizes); sizes.clear(); sizes << 230 << 600; ui->splitterNote->setSizes(sizes); // connect File menu slots connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory())); connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory())); connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory())); connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote())); connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote())); connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote())); connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit())); // connect Edit menu slots connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace())); // connect Format menu slots connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold())); connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic())); connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline())); connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough())); connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList())); connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList())); connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent())); connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent())); connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors())); connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts())); connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont())); connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont())); connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont())); connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft())); connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter())); connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight())); connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify())); // connect View menu slots connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide())); connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory())); connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory())); connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote())); connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote())); // connect Help menu slots connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt())); // connect application slots connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus())); connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus())); connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString))); connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString))); connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int))); // connect category list slots connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex))); // connect note list slots connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex))); // connect text slots ui->textNote->installEventFilter((this)); // connect system tray icon connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); // initialize default data ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent); }