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

📄 mpviewoptionwindow.cc

📁 c++的guiQt做的开发
💻 CC
字号:
/** @file MPViewOptionWindow - widget for editing program options Options are arranged to tabs and it is ensured, that only one dialog at once is active (via Private constructor and static method to invoke the dialog, which will focus on existing dialog if it exists, instead of creating second one) @author Martin Petricek*/#include "mpviewoptionwindow.h"#include "config.h"#include "fileoption.h"#include "lookandfeel.h"#include "menu.h"#include "option.h"#include "settings.h"#include "toolbar.h"#include "util.h"#include "main.h"#include "version.h"#include <lang.h>#include <assert.h>#include <QApplication>#include <QDir>#include <QStyleFactory>#include <stdlib.h>namespace gui {using namespace std;/** The only Option window<br> Pointer to running MPViewOptionWindow instance or NULL if none active.*/MPViewOptionWindow *opt=NULL;/** Invoke option dialog. Ensure only one copy is running at time @param msystem Menu system reference for given option window (needed to get toolbar list)*/void MPViewOptionWindow::optionsDialog(Menu *msystem) { if (opt) { //the dialog is already active  opt->activateWindow(); } else { //create new dialog  opt=new MPViewOptionWindow(msystem);  opt->show(); }}/** Default constructor of option window. @param msystem Menu system (Needed for toolbar list) @param parent parent widget containing this control */MPViewOptionWindow::MPViewOptionWindow(Menu *msystem,QWidget *parent /*=0*/) : OptionWindow(QString(APP_NAME)+" - "+tr("options"),parent,"option") { menuSystem=msystem; setLeftCornerText("~/" CONFIG_DIR "/" CONFIG_FILE); setUpdatesEnabled(false); init(); setUpdatesEnabled(true);}/** Add Option to the window (type of option is file) @param otab Tab holding that option @param caption Label for this option @param key Key of the given option @param defValue Default value if option not found in configuration */void MPViewOptionWindow::addOptionFile(QWidget *otab,const QString &caption,const QString &key,const QString &defValue/*=QString::null*/) { addOption(otab,caption,new FileOption(key,otab,defValue));}/** Initialize window with options */void MPViewOptionWindow::init() { QWidget *edit_tab=addTab(tr("Viewer")); addOptionBool(edit_tab,tr("Remember path of last opened/saved file"),"history/save_filePath",true); addOptionBool(edit_tab,tr("Enable undo"),"undo",true); addText      (edit_tab,tr("Undo will use extra memory to remember original image")); addOptionBool(edit_tab,tr("Hide viewer window when capturing screen"),"capture/hide"); addOptionInt (edit_tab,tr("Delay when capturing screen (in milliseconds)"),"capture/delay"); addText      (edit_tab,tr("After hiding window, application need some time to rapaint themselves.<br>Adjust the delay according to your computer speed")); addOptionBool(edit_tab,tr("Center images smaller than window"),"view/center"); addOptionBool(edit_tab,tr("Confirm file delete"),"view/confirm_delete"); finishTab    (edit_tab); QWidget *data_tab=addTab(tr("Paths")); addText  (data_tab,tr("You can use environment variables (for example $HOME) in settings on this page")); addOption(data_tab,tr("Icon Path"),"path/icon"); addOptionFile(data_tab,tr("Console log file"),"path/console_log"); finishTab(data_tab); QWidget *tool_tab=addTab(tr("Toolbars")); addText(tool_tab,tr("These toolbars will be shown:")); QStringList tbs=menuSystem->getToolbarList(); for (int i=0;i<tbs.count();i++) {  ToolBar* tb=menuSystem->getToolbar(tbs[i]);  if (!tb) continue; //Someone put invalid toolbar in settings. Just ignore it  addOptionBool(tool_tab,tb->windowTitle(),QString("toolbar/")+tbs[i],true); } finishTab(tool_tab); QWidget *laf_tab=addTab(tr("Look and Feel")); //Get list of styles QStringList styles=QStyleFactory::keys(); styles.prepend(""); //Get list of icon themes QStringList iconPath=globalSettings->readPath("icon"); QStringList iconThemes; for (int pth=0;pth<iconPath.count();pth++) {  QDir dir(iconPath[pth]);  if (dir.isReadable()) {   iconThemes+=dir.entryList(QDir::Dirs);  } } //Remove . and .. directories iconThemes.removeAll("."); iconThemes.removeAll(".."); //theme cannot be named 'default' iconThemes.removeAll("default"); //Sort list iconThemes.sort(); //Remove duplicates QString lastTheme; QStringList iconThemesUnique; for (QStringList::Iterator it=iconThemes.begin();it!=iconThemes.end();++it) {  if (*it!=lastTheme) {   lastTheme=*it;   iconThemesUnique+=lastTheme;  } } //prepend 'default' to list iconThemesUnique.prepend("default"); //Language list QStringList languages=listTranslations(); languages.prepend("en"); QStringList languageDesc=languages; for (int lng=0;lng<languageDesc.count();lng++) {  languageDesc[lng]+=": "+languageName(languageDesc[lng]); } languageDesc.prepend(tr("(system default)")); languages.prepend(""); //Default font QString defFont=QApplication::font().toString(); addText       (laf_tab,tr("You can set fonts used in application")); addOptionFont (laf_tab,tr("Application font"),"gui/font_main",defFont); addOptionFont (laf_tab,tr("Console font"),"gui/font_con",defFont); addOptionFont (laf_tab,tr("Statusbar font"),"gui/font_status",defFont); addText       (laf_tab,tr("You can specify overall visual style")); addOptionCombo(laf_tab,tr("Style"),"gui/style",styles); addOptionCombo(laf_tab,tr("Icon theme"),"icon/theme/current",iconThemesUnique); addOptionInt  (laf_tab,tr("Size of icons"),"icon/size"); addText       (laf_tab,tr("You can override application language specified by LC_ALL, LC_MESSAGE or LANG environment variables")); addOptionCombo(laf_tab,tr("Language"),"gui/language",languages,languageDesc); finishTab     (laf_tab);}/** Called after pushing 'Apply' button */void MPViewOptionWindow::postApply() { applyLookAndFeel(); //TODO: Should deinit+init only when translation changes instead. Or possibly update the translation without reinit ... //TODO: or at least retrieve and re-set current tab/* TODO: only on language change clear(); init();*/}/** default destructor */MPViewOptionWindow::~MPViewOptionWindow() { opt=NULL;//No instance active now}} // namespace gui

⌨️ 快捷键说明

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