⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preferencesdlg.cpp

📁 用qt4 编写的局域网聊天工具
💻 CPP
📖 第 1 页 / 共 3 页
字号:
      case Filtration :        break;      case Smiles :        idx = m_smilesThemeChooser->currentRow();        if(idx >= 0)          emit wantChangeSmileTheme(m_smilesThemes[idx]);        break;      case Misc :        break;      case StyleSheets :        idx = m_styleSheetsChooser->currentRow();        if(idx >= 0)          emit styleSheetChanged(m_styleSheets[idx]);        break;      case Plugins :        break;      case LastSection :        break;    }    QChatSettings::settings()->setMyColor  (m_myColor    ->color());    QChatSettings::settings()->setSysColor (m_sysColor   ->color());    QChatSettings::settings()->setBaseColor(m_baseColor  ->color());    QChatSettings::settings()->setOption   ("OutputPort", m_portOutSpbx->value());    QString str = "";    if(!m_networkIfCmbx->currentIndex())    {      str = m_broadcastEdit->text();      if(!QHostAddress(str).isNull())        QChatSettings::settings()->setOption("CustomBroadcast", str);      str = m_ipEdit->text();      if(!QHostAddress(str).isNull())        QChatSettings::settings()->setOption("CustomIP", str);    }    str = m_broadcastEdit->text();    if(!QHostAddress(str).isNull())      QChatSettings::settings()->setOption("Broadcast", str);    str = m_ipEdit->text();    if(!QHostAddress(str).toString().isEmpty())      QChatSettings::settings()->setOption("IP", str);    emit ipTextChanged(str);    if(QChatSettings::settings()->intOption("InputPort") != (int)m_portInSpbx->value())      emit portChanged(m_portInSpbx->value());    QChatSettings::settings()->setExecuteCommandOnIncomingMsg(m_commandOnIncomingEdit->text());    QChatSettings::settings()->setOption("NLFormat", m_nlFormatEdit->text());    QChatSettings::settings()->setOption("DisplayMessagesFormat", m_displayMsgFmtEdit->text());    QChatSettings::settings()->setHistoryReqTimeout(m_msgsHistoryIntervalSpbx->value());    QChatSettings::settings()->setNHistoryMsgs(m_msgsHistoryNumSpbx->value());    QChatSettings::settings()->setUsersListRefreshInterval(m_ulRefreshIntervalSpbx->value());    QChatSettings::settings()->setUsersListDeepRefreshInterval(m_ulDeepRefreshIntervalSpbx->value());    emit ulRefreshIntervalChanged(m_ulRefreshIntervalSpbx->value());    emit ulDeepRefreshIntervalChanged(m_ulDeepRefreshIntervalSpbx->value());    QChatSettings::settings()->setOption("UseAnimatedSmiles", m_useAnimatedSmilesChbx->checkState() == Qt::Checked);    QChatSettings::settings()->setSmilesPolicy(m_smilesPolicyCmbx->currentIndex());    emit useAnimatedSmiles(m_useAnimatedSmilesChbx->checkState() == Qt::Checked);  }  m_edited = false;  m_applyBtn->setEnabled(false);}//\*****************************************************************************void PreferencesDlg::slot_cancel(){  m_edited = false;  m_applyBtn->setEnabled(false);  reject();}//\*****************************************************************************void PreferencesDlg::slot_validateIp(const QString & str){  if((QHostAddress(str).isNull()))    return;  edited();}void PreferencesDlg::retranslate(){  m_myColorLab           ->setText(tr("Color of My Messages : "));  m_sysColorLab          ->setText(tr("Color of System Messages : "));  m_baseColorLab         ->setText(tr("Base Color for Messages : "));  m_ipLab                ->setText(tr("IP Address : "));  m_broadcastLab         ->setText(tr("Broadcast Address : "));  m_nlFormatLab          ->setText(tr("Now Listening string : \n(%t - Track, %a - Artist, %b - alBum)"));  m_colorsGrbx           ->setTitle(tr("&Colors"));  m_networkGrbx          ->setTitle(tr("&Network"));  m_miscGrbx             ->setTitle(tr("&Misc"));  m_nowListeningGrbx     ->setTitle(tr("Now &Listening (from Amarok1)"));  m_smilesThemesGrbx     ->setTitle(tr("Choose smiles theme:"));  m_usersListGrbx        ->setTitle(tr("Users List"));  m_styleSheetsGrbx      ->setTitle(tr("Choose Style Sheet :"));  m_pluginsGrbx          ->setTitle(tr("Available Plugins :"));  m_iconFormatGrbx       ->setTitle(tr("Users List Icon Format :"));  m_filtrationGrbx       ->setTitle(tr("Filtration rules :"));  m_protocolsGrbx        ->setTitle(tr("Choose protocol version :"));  m_okBtn                ->setText (tr("&OK"));  m_cancelBtn            ->setText (tr("&Cancel"));  m_applyBtn             ->setText (tr("&Apply"));  m_colorWholeMsgChbx    ->setText (tr("Color Whole Message"));  m_colorWholeSysMsgChbx ->setText (tr("Color Whole System Message"));  m_activateOnMsgInChbx  ->setText (tr("Activate Window on Incomin Messages"));  m_soundOnMsgInChbx     ->setText (tr("Play Sound on Incomig Messages"));  m_nlWithMessageChbx    ->setText (tr("Send 'Now Listening' with messages"));  m_nlInStatusChbx       ->setText (tr("Set 'Now Listening' in status description"));  m_portOutLab           ->setText (tr("Output Port : "));  m_portInLab            ->setText (tr("Input Port : "));  m_profileSection       ->setText(tr("Profile"));  m_miscSection          ->setText(tr("Misc"));  m_messagesSection      ->setText(tr("Messages"));  m_networkSection       ->setText(tr("Network"));  m_smilesSection        ->setText(tr("Smiles"));  m_styleSheetsSection   ->setText(tr("Style Sheets"));  m_pluginsSection       ->setText(tr("Plugins"));  m_filtrationSection    ->setText(tr("Filtration"));  m_isCommandOnIncomingChbx ->setText(tr("Execute command on incoming messages :"));  m_displayMsgFmtLab        ->setText(tr("Messages display format : "));  m_msgsHistoryIntervalLab  ->setText(tr("Messages history request interval : "));  m_msgsHistoryNumLab       ->setText(tr("Maximum number of messages in history answer : "));  m_ulRefreshIntervalLab    ->setText(tr("Refresh Interval : "));  m_ulDeepRefreshIntervalLab->setText(tr("Deep Refresh Interval : "));  m_networkIfLab            ->setText(tr("Choose Network Settings :"));  m_msgsHistoryIntervalSpbx  ->setSuffix(tr(" ms", "milliseconds"));  m_ulRefreshIntervalSpbx    ->setSuffix(tr(" s", "seconds"));  m_ulDeepRefreshIntervalSpbx->setSuffix(tr(" s", "seconds"));  m_loadUnloadPluginBtn      ->setText(tr("Load Plugin"));  m_useCompressionChbx       ->setText(tr("Use Compression"));  m_useAnimatedSmilesChbx    ->setText(tr("Use Animated Smiles"));  m_smilesPolicyLab          ->setText(tr("Smiles Policy :"));  int idx = m_smilesPolicyCmbx->currentIndex();  m_smilesPolicyCmbx->clear();  m_smilesPolicyCmbx->addItem(tr("Don't use Graphic Smiles"));  m_smilesPolicyCmbx->addItem(tr("Use only smiles from local theme"));  m_smilesPolicyCmbx->addItem(tr("Use smiles from sender"));  m_smilesPolicyCmbx->addItem(tr("Always use smiles from sender"));  m_smilesPolicyCmbx->setCurrentIndex(idx);  m_protocolV3Rbtn->setText(tr("Old protocol"));  m_protocolV4Rbtn->setText(tr("New protocol"));  setWindowTitle(tr("Preferences"));}void PreferencesDlg::createWidgets(){  m_messageFilterEditor       = new MessageFilterEditor(this);  m_colorsGrbx                = new QGroupBox(this);  m_networkGrbx               = new QGroupBox(this);  m_miscGrbx                  = new QGroupBox(this);  m_nowListeningGrbx          = new QGroupBox(this);  m_smilesThemesGrbx          = new QGroupBox(this);  m_usersListGrbx             = new QGroupBox(this);  m_styleSheetsGrbx           = new QGroupBox(this);  m_pluginsGrbx               = new QGroupBox(this);  m_iconFormatGrbx            = new QGroupBox(this);  m_filtrationGrbx            = new QGroupBox(this);  m_protocolsGrbx             = new QGroupBox(this);  m_sectionsChooser           = new QListWidget(this);  m_smilesThemeChooser        = new QListWidget(this);  m_styleSheetsChooser        = new QListWidget(this);  m_pluginsChooser            = new QListWidget(this);  m_networkSection            = new QListWidgetItem();  m_messagesSection           = new QListWidgetItem();  m_smilesSection             = new QListWidgetItem();  m_miscSection               = new QListWidgetItem();  m_profileSection            = new QListWidgetItem();  m_styleSheetsSection        = new QListWidgetItem();  m_pluginsSection            = new QListWidgetItem();  m_filtrationSection         = new QListWidgetItem();  m_sections                  = new QStackedWidget(this);  m_myColor                   = new ColorLabel(this, QChatSettings::settings()->myColor());  m_sysColor                  = new ColorLabel(this, QChatSettings::settings()->sysColor());  m_baseColor                 = new ColorLabel(this, QChatSettings::settings()->baseColor());  m_okBtn                     = new QPushButton(this);  m_cancelBtn                 = new QPushButton(this);  m_applyBtn                  = new QPushButton(this);  m_ipEdit                    = new QLineEdit(this);  m_broadcastEdit             = new QLineEdit(this);  m_portOutSpbx               = new QSpinBox (this);  m_portInSpbx                = new QSpinBox (this);  m_colorWholeMsgChbx         = new QCheckBox(this);  m_colorWholeSysMsgChbx      = new QCheckBox(this);  m_activateOnMsgInChbx       = new QCheckBox(this);  (m_soundOnMsgInChbx         = new QCheckBox(this))->hide();  m_nlWithMessageChbx         = new QCheckBox(this);  m_nlInStatusChbx            = new QCheckBox(this);  m_portOutLab                = new QLabel(this);  m_portInLab                 = new QLabel(this);  m_myColorLab                = new QLabel(this);  m_sysColorLab               = new QLabel(this);  m_baseColorLab              = new QLabel(this);  m_ipLab                     = new QLabel(this);  m_broadcastLab              = new QLabel(this);  m_nlFormatLab               = new QLabel(this);  m_displayMsgFmtLab          = new QLabel(this);  m_msgsHistoryIntervalLab    = new QLabel(this);  m_msgsHistoryNumLab         = new QLabel(this);  m_ulRefreshIntervalLab      = new QLabel(this);  m_ulDeepRefreshIntervalLab  = new QLabel(this);  m_networkIfLab              = new QLabel(this);  m_smilesPolicyLab           = new QLabel(this);  m_commandOnIncomingEdit     = new QLineEdit(this);  m_isCommandOnIncomingChbx   = new QCheckBox(this);  m_nlFormatEdit              = new QLineEdit(this);  m_displayMsgFmtEdit         = new QLineEdit(this);  m_msgsHistoryIntervalSpbx   = new QSpinBox(this);  m_msgsHistoryNumSpbx        = new QSpinBox(this);  m_ulRefreshIntervalSpbx     = new QSpinBox(this);  m_ulDeepRefreshIntervalSpbx = new QSpinBox(this);  m_networkIfCmbx             = new QComboBox(this);  m_ipListEditor              = new IpListEditor(this);  m_loadUnloadPluginBtn       = new QPushButton(this);  m_useCompressionChbx        = new QCheckBox(this);  m_useAnimatedSmilesChbx     = new QCheckBox(this);  m_smilesPolicyCmbx          = new QComboBox(this);  m_protocolsBgrp             = new QButtonGroup(this);  m_protocolV3Rbtn            = new QRadioButton(this);  m_protocolV4Rbtn            = new QRadioButton(this);  m_sectionsChooser->insertItem(Network    , m_networkSection);  m_sectionsChooser->insertItem(Messages   , m_messagesSection);  m_sectionsChooser->insertItem(Filtration , m_filtrationSection);  m_sectionsChooser->insertItem(Smiles     , m_smilesSection);  m_sectionsChooser->insertItem(Misc       , m_miscSection);  m_sectionsChooser->insertItem(StyleSheets, m_styleSheetsSection);  m_sectionsChooser->insertItem(Plugins    , m_pluginsSection);  m_msgsHistoryNumSpbx       ->setRange(-1, 100000);  m_msgsHistoryIntervalSpbx  ->setRange(0, 100000);  m_ulRefreshIntervalSpbx    ->setRange(0, 100000);  m_ulDeepRefreshIntervalSpbx->setRange(0, 100000);}void PreferencesDlg::setupConnections(){  connect(m_sectionsChooser, SIGNAL(currentRowChanged(int)), this, SLOT(slot_activateSection(int)));  connect(m_myColor  , SIGNAL(clicked()), this, SLOT(slot_chooseColor()));  connect(m_sysColor , SIGNAL(clicked()), this, SLOT(slot_chooseColor()));  connect(m_baseColor, SIGNAL(clicked()), this, SLOT(slot_chooseColor()));  connect(m_okBtn    , SIGNAL(clicked()), this, SLOT(slot_setPrefs()));  connect(m_okBtn    , SIGNAL(clicked()), this, SLOT(slot_accept  ()));  connect(m_applyBtn , SIGNAL(clicked()), this, SLOT(slot_setPrefs()));  connect(m_cancelBtn, SIGNAL(clicked()), this, SLOT(slot_cancel  ()));  connect(m_colorWholeSysMsgChbx, SIGNAL(stateChanged(int)), this, SLOT(slot_setSysMsgColorMode(int)));  connect(m_colorWholeMsgChbx   , SIGNAL(stateChanged(int)), this, SLOT(slot_setMsgColorMode   (int)));  connect(m_activateOnMsgInChbx , SIGNAL(stateChanged(int)), this, SLOT(slot_setActivateOnMsgIn(int)));  connect(m_soundOnMsgInChbx    , SIGNAL(stateChanged(int)), this, SLOT(slot_setSoundOnMsgIn   (int)));  connect(m_nlInStatusChbx      , SIGNAL(stateChanged(int)), this, SLOT(slot_setNlInStatus     (int)));  connect(m_nlWithMessageChbx   , SIGNAL(stateChanged(int)), this, SLOT(slot_setNlWithMessage  (int)));  connect(m_portInSpbx               , SIGNAL(valueChanged(int)), this, SLOT(edited()));  connect(m_portOutSpbx              , SIGNAL(valueChanged(int)), this, SLOT(edited()));  connect(m_msgsHistoryIntervalSpbx  , SIGNAL(valueChanged(int)), this, SLOT(edited()));  connect(m_msgsHistoryNumSpbx       , SIGNAL(valueChanged(int)), this, SLOT(edited()));  connect(m_ulRefreshIntervalSpbx    , SIGNAL(valueChanged(int)), this, SLOT(edited()));  connect(m_ulDeepRefreshIntervalSpbx, SIGNAL(valueChanged(int)), this, SLOT(edited()));  connect(m_ipEdit               , SIGNAL(textChanged (QString)), this, SLOT(slot_validateIp(QString)));  connect(m_broadcastEdit        , SIGNAL(textChanged (QString)), this, SLOT(slot_validateIp(QString)));  connect(m_commandOnIncomingEdit, SIGNAL(textChanged (QString)), this, SLOT(edited()));  connect(m_nlFormatEdit         , SIGNAL(textChanged (QString)), this, SLOT(edited()));  connect(m_displayMsgFmtEdit    , SIGNAL(textChanged (QString)), this, SLOT(edited()));  if(!QChatSettings::settings()->boolOption("AllowDifferentPorts"))    connect(m_portInSpbx, SIGNAL(valueChanged(int)), m_portOutSpbx, SLOT(setValue(int)));  connect(m_networkIfCmbx, SIGNAL(activated(int)), this, SLOT(setNetworkIf(int)));  connect(m_isCommandOnIncomingChbx, SIGNAL(stateChanged(int)), this, SLOT(slot_setExecuteCommandMode(int)));  connect(m_loadUnloadPluginBtn, SIGNAL(clicked()), this, SLOT(loadOrUnloadPlugin()));  connect(m_useCompressionChbx , SIGNAL(stateChanged(int)), this, SLOT(setUseCompression(int)));  connect(m_smilesPolicyCmbx     , SIGNAL(activated(int))   , this, SLOT(edited()));  connect(m_useAnimatedSmilesChbx, SIGNAL(stateChanged(int)), this, SLOT(edited()));  connect(m_protocolV3Rbtn, SIGNAL(toggled(bool)), this, SLOT(protocolChanged()));  connect(m_protocolV4Rbtn, SIGNAL(toggled(bool)), this, SLOT(protocolChanged()));}void PreferencesDlg::setupSections(){  QList<QWidget*> list;  m_sectionsChooser->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);  m_sectionsChooser->setFixedWidth(150);  // Network  m_sections->insertWidget(Network, setupSectionLayout(m_networkGrbx));  list.append(m_colorsGrbx);  list.append(m_miscGrbx);  list.append(m_displayMsgFmtLab);  list.append(m_displayMsgFmtEdit);  list.append(m_msgsHistoryIntervalLab);  list.append(m_msgsHistoryIntervalSpbx);  list.append(m_msgsHistoryNumLab);  list.append(m_msgsHistoryNumSpbx);  // Messages  m_sections->insertWidget(Messages, setupSectionLayout(list));  // Filtration  m_sections->insertWidget(Filtration, m_filtrationGrbx);  // Smiles  connect(m_smilesThemeChooser, SIGNAL(currentRowChanged(int)), this, SLOT(edited()));  m_sections->insertWidget(Smiles, m_smilesThemesGrbx);  // Misc  list.clear();#if defined(Q_OS_LINUX)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -