void MainWindow::setupActions() { //file menu KStdAction::openNew(this, SLOT(slotNewFile()), actionCollection()); KStdAction::open(this, SLOT(slotOpenFile()), actionCollection()); m_actionRecent = KStdAction::openRecent(this, SLOT(slotFileRecent(const KURL&)), actionCollection()); m_actionRecent->loadEntries(kapp->config());//,"Recent Files"); KStdAction::save(this, SLOT(slotSaveCurrentFile()), actionCollection()); KStdAction::saveAs(this, SLOT(slotSaveCurrentFileAs()), actionCollection()); KStdAction::close(this, SLOT(slotCloseFile()), actionCollection()); (void)new KAction(i18n("Close All"), 0, this, SLOT(slotCloseAllFiles()), actionCollection(), "file_close_all"); KStdAction::quit(this, SLOT(slotQuit()), actionCollection()); KStdAction::keyBindings(this, SLOT(slotEditKeys()), actionCollection()); KStdAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection()); KStdAction::preferences(this, SLOT(slotShowSettings()), actionCollection(), "settings_gpteditor"); (void)new KAction(i18n("Compile"), "make_kdevelop", "F10", m_debugger_manager, SLOT(slotCompileApplication()), actionCollection(), "compile_application"); (void)new KAction(i18n("Run"), "gear", "F9", m_debugger_manager, SLOT(slotRunApplication()), actionCollection(), "run_application"); (void)new KAction(i18n("Start Debug"), "dbgstart", "F5", m_debugger_manager, SLOT(slotDebugStart()), actionCollection(), "debug_start"); (void)new KAction(i18n("Stop Debug"), "stop", "Escape", m_debugger_manager, SLOT(slotDebugStop()), actionCollection(), "debug_stop"); (void)new KAction(i18n("Step Over"), "dbgnext", "F6", m_debugger_manager, SLOT(slotDebugStepOver()), actionCollection(), "debug_step_over"); (void)new KAction(i18n("Step Into"), "dbgstep", "F7", m_debugger_manager, SLOT(slotDebugStepInto()), actionCollection(), "debug_step_into"); (void)new KAction(i18n("Step Out"), "dbgstepout", "F8", m_debugger_manager, SLOT(slotDebugStepOut()), actionCollection(), "debug_step_out"); // (void)new KAction(i18n("Profile (DBG only)"), "math_sum", "Alt+P", m_debugger_manager, // SLOT(slotProfile()), actionCollection(), "script_profile"); (void)new KAction(i18n("Toggle Breakpoint"), "activebreakpoint", "Alt+B", m_debugger_manager, SLOT(slotDebugToggleBp()), actionCollection(), "debug_toggle_bp"); // (void)new KAction("", "math_brace", 0, m_tabEditor, // SLOT(slotAddWatch()), actionCollection(), "editor_add_watch"); // Editor default action setStandardToolBarMenuEnabled(true); }
void MainWindow::setupActions() { //file menu KStdAction::open(this, SLOT(slotOpenFile()), actionCollection()); m_actionRecent = KStdAction::openRecent(this, SLOT(slotFileRecent(const KURL&)), actionCollection()); m_actionRecent->loadEntries(kapp->config());//,"Recent Files"); KStdAction::close(this, SLOT(slotCloseFile()), actionCollection()); (void)new KAction(i18n("Close All"), 0, this, SLOT(slotCloseAllFiles()), actionCollection(), "file_close_all"); KStdAction::quit(this, SLOT(slotQuit()), actionCollection()); KStdAction::keyBindings(this, SLOT(slotEditKeys()), actionCollection()); KStdAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection()); KStdAction::preferences(this, SLOT(slotShowSettings()), actionCollection(), "settings_protoeditor"); m_siteAction = new KSelectAction("Site", 0, actionCollection(), "site_selection"); connect(m_siteAction, SIGNAL(activated(const QString&)), ProtoeditorSettings::self(), SLOT(slotCurrentSiteChanged(const QString&))); m_defaultScriptAction = new KSelectAction("Default script", 0, actionCollection(), "default_script"); QStringList l; l << "Site Script" << "Active Script"; m_defaultScriptAction->setItems(l); m_defaultScriptAction->setCurrentItem(0); // connect(m_defaultScriptAction, SIGNAL(activated(int)), // this, SLOT(slotDefaultScriptChanged(int))); // (void)new KAction(i18n("&Run"), "gear", "F9", m_debugger_manager, // SLOT(slotDebugStart()), actionCollection(), "script_run_current_script"); (void)new KAction(i18n("Start Debug"), "dbgstart", "F5", m_debugger_manager, SLOT(slotDebugStart()), actionCollection(), "debug_start"); (void)new KAction(i18n("Stop Debug"), "stop", "Escape", m_debugger_manager, SLOT(slotDebugStop()), actionCollection(), "debug_stop"); (void)new KAction(i18n("Step Over"), "dbgnext", "F6", m_debugger_manager, SLOT(slotDebugStepOver()), actionCollection(), "debug_step_over"); (void)new KAction(i18n("Step Into"), "dbgstep", "F7", m_debugger_manager, SLOT(slotDebugStepInto()), actionCollection(), "debug_step_into"); (void)new KAction(i18n("Step Out"), "dbgstepout", "F8", m_debugger_manager, SLOT(slotDebugStepOut()), actionCollection(), "debug_step_out"); (void)new KAction(i18n("Profile"), "math_sum", "Alt+P", m_debugger_manager, SLOT(slotProfile()), actionCollection(), "script_profile"); (void)new KAction(i18n("Toggle Breakpoint"), "activebreakpoint", "Alt+B", m_debugger_manager, SLOT(slotDebugToggleBp()), actionCollection(), "debug_toggle_bp"); (void)new KAction("", "math_brace", 0, m_tabEditor, SLOT(slotAddWatch()), actionCollection(), "editor_add_watch"); setStandardToolBarMenuEnabled(true); }
//------------------------------------------------------------------------------------------------- ExchangeRate::ExchangeRate() : QWidget(), nam(new QNetworkAccessManager(this)), iPrecision(2), bUseProxy(false), bProxyIsSocks(false), iPort(3128), bAuth(false), dMaxSum(100000000000000000000.05) { const QString strAppName = qAppName(), strAppDir = qApp->applicationDirPath(); strAppStg = strAppDir + '/' + strAppName + ".ini"; QTranslator *translator = new QTranslator(this); if (translator->load(strAppName, strAppDir) || translator->load(strAppName + '_' + QLocale::system().name(), strAppDir)) qApp->installTranslator(translator); leUah = new QLineEdit(this); QVBoxLayout *vblSpacing = new QVBoxLayout; vblSpacing->addSpacing(15); leUsd = new QLineEdit(this); leEur = new QLineEdit(this); leRub = new QLineEdit(this); gbMain = new QGroupBox(this); gbMain->setEnabled(false); QFormLayout *frml = new QFormLayout(gbMain); frml->addRow("UAH:", leUah); frml->addRow(vblSpacing); frml->addRow("USD:", leUsd); frml->addRow("EUR:", leEur); frml->addRow("RUB:", leRub); QPushButton *pbUpdate = new QPushButton(style()->standardIcon(QStyle::SP_BrowserReload), tr("Update"), this); lblInfo = new QLabel(this); QFont fontSaved = lblInfo->font(); fontSaved.setItalic(true); lblInfo->setFont(fontSaved); QHBoxLayout *hblUpdate = new QHBoxLayout; hblUpdate->setContentsMargins(0, 0, 0, 0); hblUpdate->addWidget(pbUpdate); hblUpdate->addWidget(lblInfo); lblNote = new QLabel("?\n1 USD = ?\n1 EUR = ?\n1 UAH = ?", this); QGroupBox *gbNote = new QGroupBox(this); gbNote->setMinimumWidth(170); QVBoxLayout *vbNote = new QVBoxLayout(gbNote); vbNote->addLayout(hblUpdate); vbNote->addWidget(lblNote); QLabel *lblVer = new QLabel(cFullVersion, this); QPushButton *pbSettings = new QPushButton(style()->standardIcon(QStyle::SP_FileDialogDetailedView), 0, this); QHBoxLayout *hblBottom = new QHBoxLayout; hblBottom->addStretch(); hblBottom->addWidget(lblVer); hblBottom->addWidget(pbSettings); QVBoxLayout *vblRight = new QVBoxLayout; vblRight->addWidget(gbNote); vblRight->addLayout(hblBottom, Qt::AlignRight); QHBoxLayout *hblMain = new QHBoxLayout(this); hblMain->addWidget(gbMain); hblMain->addLayout(vblRight); this->setMaximumHeight(this->minimumSizeHint().height()); //connects connect(leUah, SIGNAL(textEdited(QString)), this, SLOT(slotFromUah(QString))); connect(leUsd, SIGNAL(textEdited(QString)), this, SLOT(slotFromUsd(QString))); connect(leEur, SIGNAL(textEdited(QString)), this, SLOT(slotFromEur(QString))); connect(leRub, SIGNAL(textEdited(QString)), this, SLOT(slotFromRub(QString))); connect(pbUpdate, SIGNAL(clicked()), this, SLOT(slotUpdate())); connect(pbSettings, SIGNAL(clicked()), this, SLOT(slotShowSettings())); connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotReplyFin(QNetworkReply*))); //settings QSettings stg(strAppStg, QSettings::IniFormat); stg.setIniCodec("UTF-8"); if (stg.childGroups().contains("Settings")) { stg.beginGroup("Settings"); const QString strDate = stg.value("DateTime").toString(); if (QDateTime::fromString(strDate, "dd.MM.yyyy").isValid() && (dUahPerUsd = stg.value("USD").toDouble()) > 3.0 && dUahPerUsd < 80.0 && (dUahPerEur = stg.value("EUR").toDouble()) > 3.0 && dUahPerEur < 80.0 && (dUahPerRub = stg.value("RUB").toDouble()) > 0.1 && dUahPerRub < 1.0) { lblNote->setText(strDate + "\n1 USD = " + QString::number(dUahPerUsd, 'f', 6) + " UAH\n1 EUR = " + QString::number(dUahPerEur, 'f', 6) + " UAH\n1 UAH = " + QString::number(1.0/dUahPerRub, 'f', 6) + " RUB"); gbMain->setEnabled(true); } int iTemp = stg.value("Precision", -1).toInt(); if (iTemp >= 0 && iTemp <= 10) iPrecision = iTemp; if (stg.value("UseProxy").toString() == "1") bUseProxy = true; if (stg.value("ProxyType") == "SOCKS5") bProxyIsSocks = true; strServer = stg.value("Server").toString(); iTemp = stg.value("Port").toInt(); if (iTemp > 0 && iTemp <= 65535) iPort = iTemp; if (stg.value("Auth").toString() == "1") bAuth = true; strUser = stg.value("User").toString(); strPassword = stg.value("Password").toString(); stg.endGroup(); if (bUseProxy) { QNetworkProxy netProxy(bProxyIsSocks ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy, strServer, iPort); if (bAuth) { netProxy.setUser(strUser); netProxy.setPassword(strPassword); } nam->setProxy(netProxy); } } this->restoreGeometry(QSettings("UserPrograms", strAppName).value("Geometry").toByteArray()); }