MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QSettings settings ("binaervarianz.de", "FollowMe"); restoreGeometry(settings.value("geometry", saveGeometry()).toByteArray()); restoreState(settings.value("windowState", saveState()).toByteArray()); mfilelist= new FMFileList(parent); model = new QFileSystemModel; QString extPath = settings.value("extPath",QDir::homePath()).toString(); model->setRootPath(extPath ); list = new QTreeView(this); updateFileBrowser(extPath); setCentralWidget(list); QAction *prefAct = new QAction(tr("&Preferences..."), this); prefAct->setShortcuts(QKeySequence::Preferences); prefAct->setStatusTip(tr("Open preference pane")); connect(prefAct, SIGNAL(triggered()), this, SLOT(openPreferences())); QMenuBar* menu = menuBar(); QMenu* fileMenu = menu->addMenu(tr("&File")); fileMenu->addAction(prefAct); ui = new PreferenceDialog2(this); }
void MainWindow::openFile(QString fileName) { if (fileName.isEmpty()) { fileName = QFileDialog::getOpenFileName( this, tr("Open File"), desktopServices.storageLocation(QDesktopServices::DocumentsLocation), tr("Fabula Files (*.fabula)")); } if (!fileName.isEmpty()) { if (database) { delete database; database = 0; } database = new Database(fileName); settings.setValue("database", fileName); eventsFilterModel->setSourceModel(database->events()); hideEventsTableColumnsModel->setSourceModel(database->events()); conversationsTreeModel->setSourceModel(hideEventsTableColumnsModel); setWindowTitle(QString("%1 - Fabula").arg(fileName)); ui->centralWidget->setEnabled(true); if (!PreferencesDialog::haveWriter()) // Post an event so it's done after object construction QTimer::singleShot(0, this, SLOT(openPreferences())); } else { if (!database) { ui->centralWidget->setEnabled(false); } } }
//! \brief create the action with in the right clic on the icon void TrayIcon::createActions() { //-------------------------------------------------- // Pour mettre une image dans le TrayIcon QString path(":/logoBig"); _logoAction = new MyCustomActionPixmap(this, path); connect(_logoAction, SIGNAL(triggered()), this, SLOT(clickLogo())); //-------------------------------------------------- //-------------------------------------------------- // Pour mettre du text non cliquable // _testAction = new MyCustomActionLabel(this, tr("Coucou")); //-------------------------------------------------- //-------------------------------------------------- // Pour mettre du texte cliquable openFolderAction = new QAction(tr("&Open Woda folder"), this); connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openDirectory())); goWebsiteAction = new QAction(tr("&Open Woda webapp"), this); connect(goWebsiteAction, SIGNAL(triggered()), this, SLOT(openBrowserWoda())); //recentFilesAction = new QAction(tr("&Recent files"), this); friendsAction = new QAction(tr("&Manage Friendlist"), this); connect(friendsAction, SIGNAL(triggered()), this, SLOT(openFriendManager())); spaceAction = new QAction(tr("10GO (5%) used of 50GO"), this); spaceAction->setDisabled(true); getMoreAction = new QAction(tr("&Get more storage"), this); connect(getMoreAction, SIGNAL(triggered()), this, SLOT(openBrowserMoreStorage())); preferencesAction = new QAction(tr("&Preferences"), this); connect(preferencesAction, SIGNAL(triggered()), this, SLOT(openPreferences())); helpAction = new QAction(tr("&Help"), this); connect(helpAction, SIGNAL(triggered()), this, SLOT(openFileshare())); quitAction = new QAction(tr("&Quit Woda"), this); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); //-------------------------------------------------- }
/** * Setups the UI: textarea transparency, preferences restore, signals&slots. */ void MEdiText::init() { // ui setupUi(this); showFullScreen(); this->textEdit->viewport()->setAutoFillBackground(false); // signal listening connect( newBtn, SIGNAL( clicked() ), this, SLOT( createNewDocument() ) ); connect( openBtn, SIGNAL( clicked() ), this, SLOT( openExistingDocument() ) ); connect( saveBtn, SIGNAL( clicked() ), this, SLOT( saveDocument() ) ); connect( quitBtn, SIGNAL( clicked() ), this, SLOT( closeIfSaved() ) ); connect( prefsBtn, SIGNAL( clicked() ), this, SLOT( openPreferences() ) ); // preference restore this->settings = new QSettings("MEdiText", "MEdiText"); QString path = this->settings->value("background_path", "mckenzie.jpg").toString(); int alpha = this->settings->value("background_alpha", 128).toInt(); this->setBackground(path, alpha); QString family = this->settings->value("font_family", "DejaVu Sans").toString(); int size = this->settings->value("font_size", 11).toInt(); this->setFont(family, size); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), database(0), eventsFilterModel(new QSortFilterProxyModel(this)), conversationsTreeModel(new TableToTreeProxyModel(this)), hideEventsTableColumnsModel(new HideColumnsProxyModel(this)) { ui->setupUi(this); eventsFilterModel->setObjectName("eventsFilterModel"); hideEventsTableColumnsModel->setObjectName("hideEventsTableColumnsModel"); QList<int> hideColumns; hideColumns << 0 << 1 << 4 << 5; hideEventsTableColumnsModel->setHideColumns(hideColumns); conversationsTreeModel = new TableToTreeProxyModel(this); conversationsTreeModel->setObjectName("conversationsTreeModel"); QString fileName = settings.value("database").toString(); if (fileName.isEmpty() || !QFile(fileName).exists()) { newFile(); } else { openFile(fileName); } ui->statusBar->hide(); ui->splitter->setStretchFactor(1, 1); QVariant treeSize = settings.value("treeSize"); QVariant tableSize = settings.value("tableSize"); if (treeSize.isValid() && tableSize.isValid()) { QList<int> splitterSizes; splitterSizes << treeSize.toInt() << tableSize.toInt(); ui->splitter->setSizes(splitterSizes); } // TODO: Disable actions that need new e.g. characters until ready connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newFile())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openFile())); connect(ui->actionAdd_Event, SIGNAL(triggered()), this, SLOT(addEvent())); connect(ui->actionDelete_Event, SIGNAL(triggered()), this, SLOT(deleteEvent())); connect(ui->actionAdd_Conversation, SIGNAL(triggered()), this, SLOT(addConversation())); connect(ui->actionDelete_Conversation, SIGNAL(triggered()), this, SLOT(deleteConversation())); connect(ui->actionAdd_Character, SIGNAL(triggered()), this, SLOT(addCharacter())); connect(ui->actionDelete_Character, SIGNAL(triggered()), this, SLOT(deleteCharacter())); connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(openPreferences())); ui->conversationsView->installEventFilter(this); ui->eventsView->installEventFilter(this); connect(ui->conversationsView, SIGNAL(clicked(QModelIndex)), this, SLOT(filterOnConversation(QModelIndex))); ui->eventsView->setModel(eventsFilterModel); ui->eventsView->hideColumn(0); ui->eventsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); ui->eventsView->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(ui->eventsView, SIGNAL(activated(QModelIndex)), this, SLOT(editEvent(QModelIndex))); conversationsTreeModel->index(0,0).parent().isValid(); ui->conversationsView->setModel(conversationsTreeModel); ui->conversationsView->sortByColumn(0, Qt::AscendingOrder); ui->conversationsView->setEditTriggers(QAbstractItemView::NoEditTriggers); connect(ui->conversationsView, SIGNAL(activated(QModelIndex)), this, SLOT(editTreeItem(QModelIndex))); }
void NMainMenuBar::setupEditMenu() { editMenu = this->addMenu(tr("&Edit")); QFont f = global.getGuiFont(QFont()); editMenu->setFont(f); undoAction = new QAction(tr("&Undo"), this); setupShortcut(undoAction, QString("Edit_Undo")); editMenu->addAction(undoAction); redoAction = new QAction(tr("&Redo"), this); setupShortcut(redoAction, QString("Edit_Redo")); editMenu->addAction(redoAction); editMenu->addSeparator(); cutAction = new QAction(tr("&Cut"), this); setupShortcut(cutAction, QString("Edit_Cut")); editMenu->addAction(cutAction); copyAction = new QAction(tr("C&opy"), this); setupShortcut(copyAction, QString("Edit_Copy")); editMenu->addAction(copyAction); pasteAction = new QAction(tr("&Paste"), this); setupShortcut(pasteAction, QString("Edit_Paste")); editMenu->addAction(pasteAction); pasteAsTextAction = new QAction(tr("Pas&te as Unformatted Text"), this); setupShortcut(pasteAsTextAction, QString("Edit_Paste_Without_Formatting")); editMenu->addAction(pasteAsTextAction); removeFormattingAction = new QAction(tr("Remo&ve Formatting"), this); //setupShortcut(removeFormjattingAction, QString("Edit_Remove_Formatting")); // For some reason this one makes the editorButtonBar one ambiguous editMenu->addAction(removeFormattingAction); editMenu->addSeparator(); selectAllAction = new QAction(tr("Select &All"), this); setupShortcut(selectAllAction, QString("Edit_Select_All")); editMenu->addAction(selectAllAction); editMenu->addSeparator(); findReplaceMenu = editMenu->addMenu(tr("F&ind and Replace")); findReplaceMenu->setFont(f); searchNotesAction = new QAction(tr("&Search Notes"), this); setupShortcut(searchNotesAction, QString("Edit_Search_Notes")); findReplaceMenu->addAction(searchNotesAction); connect(searchNotesAction, SIGNAL(triggered()), parent->searchText, SLOT(setFocus())); resetSearchAction = new QAction(tr("&Reset Search"), this); setupShortcut(resetSearchAction, QString("Edit_Reset_Search")); findReplaceMenu->addAction(resetSearchAction); connect(resetSearchAction, SIGNAL(triggered()), parent, SLOT(resetView())); findReplaceMenu->addSeparator(); searchFindAction = new QAction(tr("&Find in Note"), this); setupShortcut(searchFindAction, QString("Edit_Search_Find")); findReplaceMenu->addAction(searchFindAction); connect(searchFindAction, SIGNAL(triggered()), parent, SLOT(findInNote())); searchFindNextAction = new QAction(tr("Find &Next"), this); setupShortcut(searchFindNextAction, QString("Edit_Search_Find_Next")); findReplaceMenu->addAction(searchFindNextAction); connect(searchFindNextAction, SIGNAL(triggered()), parent, SLOT(findNextInNote())); searchFindPrevAction = new QAction(tr("Find &Previous"), this); setupShortcut(searchFindPrevAction, QString("Edit_Search_Find_Prev")); findReplaceMenu->addAction(searchFindPrevAction); connect(searchFindPrevAction, SIGNAL(triggered()), parent, SLOT(findPrevInNote())); findReplaceMenu->addSeparator(); searchFindReplaceAction = new QAction(tr("Replace &Within Note..."), this); setupShortcut(searchFindReplaceAction, QString("Edit_Search_Find_Replace")); findReplaceMenu->addAction(searchFindReplaceAction); connect(searchFindReplaceAction, SIGNAL(triggered()), parent, SLOT(findReplaceInNote())); editMenu->addSeparator(); createThemeMenu(editMenu); preferencesAction = new QAction(tr("Preferences"), this); preferencesAction->setMenuRole(QAction::PreferencesRole); setupShortcut(preferencesAction, QString("Edit_Preferences")); editMenu->addAction(preferencesAction); connect(preferencesAction, SIGNAL(triggered()), parent, SLOT(openPreferences())); }
int mainForm::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3MainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: fileOpen((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 1: fileOpen(); break; case 2: fileNew(); break; case 3: populateStructure(); break; case 4: populateTable((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 5: resetBrowser(); break; case 6: fileClose(); break; case 7: fileExit(); break; case 8: closeEvent((*reinterpret_cast< QCloseEvent*(*)>(_a[1]))); break; case 9: addRecord(); break; case 10: deleteRecord(); break; case 11: updateTableView((*reinterpret_cast< int(*)>(_a[1]))); break; case 12: selectTableLine((*reinterpret_cast< int(*)>(_a[1]))); break; case 13: navigatePrevious(); break; case 14: navigateNext(); break; case 15: navigateGoto(); break; case 16: setRecordsetLabel(); break; case 17: browseFind((*reinterpret_cast< bool(*)>(_a[1]))); break; case 18: browseFindAway(); break; case 19: lookfor((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< const QString(*)>(_a[3]))); break; case 20: showrecord((*reinterpret_cast< int(*)>(_a[1]))); break; case 21: createTable(); break; case 22: createIndex(); break; case 23: compact(); break; case 24: deleteTable(); break; case 25: editTable(); break; case 26: deleteIndex(); break; case 27: copy(); break; case 28: paste(); break; case 29: helpWhatsThis(); break; case 30: helpAbout(); break; case 31: updateRecordText((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break; case 32: logWinAway(); break; case 33: editWinAway(); break; case 34: editText((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 35: doubleClickTable((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QPoint(*)>(_a[4]))); break; case 36: executeQuery(); break; case 37: mainTabSelected((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 38: toggleLogWindow((*reinterpret_cast< bool(*)>(_a[1]))); break; case 39: importTableFromCSV(); break; case 40: exportTableToCSV(); break; case 41: dbState((*reinterpret_cast< bool(*)>(_a[1]))); break; case 42: fileSave(); break; case 43: fileRevert(); break; case 44: exportDatabaseToSQL(); break; case 45: importDatabaseFromSQL(); break; case 46: openPreferences(); break; case 47: updatePreferences(); break; case 48: languageChange(); break; default: ; } _id -= 49; } return _id; }
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(); }