void Lvk::FE::DetailsDialog::onLinkActivated(const QString &) { alignCenter(DIALOG_DET_W, DIALOG_DET_H); ui->detailsLabel->setVisible(true); ui->detailsText->setVisible(true); ui->label->setText(m_msg); }
Lvk::FE::DetailsDialog::DetailsDialog(const QString &msg, const QString &linkMsg, const QString &details, QWidget *parent) : QDialog(parent), ui(new Ui::DetailsDialog), m_msg(msg) { QPixmap questionPix = style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(48,48); ui->setupUi(this); ui->detailsText->setPlainText(details); ui->detailsLabel->setVisible(false); ui->detailsText->setVisible(false); ui->icon->setPixmap(questionPix); QString labelText = msg; if (!linkMsg.isEmpty()) { labelText.append(QString("<br/><a href=\"#\">%1</a>").arg(linkMsg)); } ui->label->setText(labelText); alignCenter(DIALOG_INIT_W, DIALOG_INIT_H); connect(ui->label, SIGNAL(linkActivated(QString)), SLOT(onLinkActivated(QString))); connect(ui->rejectButton, SIGNAL(clicked()), SLOT(reject())); connect(ui->acceptButton, SIGNAL(clicked()), SLOT(accept())); }
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; } }
int main(void) { FILE *fp; Tree *RBT = NULL; Tree *RBT_name = NULL; int input; PlaySound(TEXT("start.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP | SND_NODEFAULT); system("mode con: cols=120"); system("color F8"); fp = fopen("data.txt", "r"); if (fp == NULL) // 데이터 읽기 실패시 { printf("데이터 로드에 실패했습니다!"); return -1; } RBT = createRBT(); RBT_name = createRBT(); roadData(fp, RBT, RBT_name); system("cls"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15 << 4 | 0); printf("..... .... .... .... ..... .... ::=:: :::. .:::::::::::: ::. ::. ::::::::::::: \n"); printf("=@@@@= .@@@: @@@= @@@= =@@@@= .@@@: #@@@@# :@@@+ +@@@@@@@@@@@@: @@@#. =@@@# @@@@@@@@@@@@@ \n"); Sleep(33); printf("=@@@@@$ .@@@: @@@: @@@= =@@@@@$ .@@@: *@@@@@# :@@@= +@@@: :@@@@* .=@@@#. :@@@+ \n"); Sleep(33); printf("=@@@+@@@ .@@@: @@@= @@@= =@@@+@@@ .@@@: *@@@@@@#. :@@@+ +@@@. +@@@@#@@@@: .@@@= \n"); Sleep(33); printf("=@@@ +@@@: .@@@: @@@@@@@@@@@@@@= =@@@ =@@@: .@@@: *@@@ #@@@: :@@@= +@@@@@@@@@@@# *@@@@@= :@@@+ \n"); Sleep(33); printf("=@@@ .@@@= @@@: @@@*+++++++@@@= =@@@ .@@@= @@@: #@@@ +@@@+.@@@+ +@@@########+ :@@@@@@* :@@@+ \n"); Sleep(33); printf("=@@@ @@@@@@@: @@@: @@@= =@@@ @@@@@@@: #@@@ =@@@@@@@+ +@@@ .#@@@#:+@@@+ :@@@+ \n"); Sleep(33); printf("=@@@ *@@@@@: @@@= @@@= =@@@ *@@@@@: *@@@ .@@@@@@+ +@@@=........ +@@@#: +@@@@: :@@@= \n"); Sleep(33); printf("=@@@ +@@@@: @@@= @@@= =@@@ +@@@@: #@@@ =@@@@+ +@@@@@@@@@@@@::@@@* .+@@@ :@@@+ \n"); Sleep(33); printf(" ... ... .. ... ... ... :::: ::::. .:::::::::::: ::. ::: :::. \n"); Sleep(33); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15 << 4 | 8); printf("\n"); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@***@@@@@**@**@@@@@@@@@************@@@*@@@@@**********@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@**@@@*****@@@@@@@@@@@@**********@@*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@****@@**@@@@@@@@@@@@@@@@@@*********@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**@@****@@@@@@**.*********@@@@@@**@**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@*@@@*@@****@@*****@@@@***.************@@@@@****@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@***@@*@*****************......***********@@@****@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@@@*@************@****...*******@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@@*****************.***@@*@@@@*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@***********************@@@**********@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@******************@*******@*****......****@@@@@@**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@****@@@**...*@******......@.*.........*****@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@@@*****.@@**...........@.*........********@@@@@@******@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**@@@@@**..........*@.*.........*******************@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@**@@@*..**.........*@*..........*********************@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@**@*...@@.....***....*@*. ........****************.....@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@@@*..**.*@.......*****....................********.*....*@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**@@@@***...*..................................*******..****@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**@@@*.....@.....****.*........................*******@****@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**@@*....*********.............................**********@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*****...***...............................************@@@@@@@@@*@@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@***.**.*******..***.......................************@@@@@@@@@*@@*...*@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.. ....*@@@@... ...**..................************@@@@@@@@@@@@@*.. *@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@*... .......*@@@@*******................***************@@@@@@@@@@@@@@*.*@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@* .......... ......*@@@****....................**************@@@@@@@@@@*@@@@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.... .******............******...................***************@@@@@@@@@...**@@@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@*. . ..*@@@*..........*****..................******************@@@@@* ...****@@@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@*. ....***... ..............***................*********************@@@. ..********@@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@. ....*****@@@@*....................****..........****************...*****@* ..***********@@@@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@**@@@*..******@@@@@@@@@@**.......... ...*****.....******************......****. ..***************@@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@********@***@@@@@@@@@*********@@*.... ... ..***************************.......**. ..*********************\n"); Sleep(33); printf("@@@@@@@@@@@*.***.****@@@@@@@@@@@@@@@@****...*@@*.........**************************.......... ...**********************\n"); Sleep(33); printf("@@@@@@@@@@@@****@@@@@@@@@@@@@@@@@@@@@@@**...*...*........***********************........... .....**********************\n"); Sleep(33); printf("@@@@@@@@@@@*@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.................**********************................****************@******\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... .............***@@@***********.......... ........***************@*******\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.. .............**.*@@*@@********...................***************@********\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*... . ..........**.... .@@*********... ...........******************@******\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...................... .*@@@@*****. .............*****************@*******\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@............... .. . ..*@@@******.............****************@*********\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*............ ... ..*@***@@*********.........****************@**********\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*...... ...********************. .***************@@***********\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*..... .************************.....***************@@************\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*..... .***************************...***************@@************@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@........ .*******************************..**************@*************@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.......************************************************@*************@@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*****....*********************************@@@*************@**************@@\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*******@*************************@@*****@**@@@@@@**********@**************@@@*\n"); Sleep(33); printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@************************************@@*********@@@@@@********@***************@@@*\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); printf("\n"); Sleep(33); system("cls"); char arr[] = "<김동률 - 출발> 재생중♬"; printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t"); for (int ii = 0; ii <= 24; ii++) { Sleep(100); printf("%c", arr[ii]); } printf("\n"); Sleep(77); printf("\n"); Sleep(77); printf("\n"); Sleep(77); //return; while (1) { system("cls"); printf("\n"); alignCenter("시작 화면\n"); printf("\n"); alignCenter("───────MENU───────\n"); alignCenter("1. 회원 목록\n"); alignCenter("2. 회원 추가\n"); alignCenter("3. 회원 수정\n"); alignCenter("4. 회원 삭제\n"); alignCenter("5. 회원 검색\n"); alignCenter("6. 파일 저장\n"); alignCenter("0. 종 료\n"); alignCenter("────────────────\n"); printf("\n"); alignCenter("버튼을 입력하세요 : "); scanf("%d", &input); switch (input) { case 1: menu1_member_view(RBT); break; case 2: menu2_member_add(RBT,RBT_name); break; case 3: menu3_member_modify(RBT, RBT_name); break; case 4: menu4_member_delete(RBT, RBT_name); break; case 5: menu5_member_search(RBT, RBT_name); break; case 6: menu6_data_save(RBT); break; case 0: menu0_close(); fclose(fp); return 0; } } fclose(fp); getch(); return 0; }
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); }
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); }