[vlc-devel] commit: a macro to automate the choice of "folder"/"directory" string version according to platform (Jakob Leben )
git version control
git at videolan.org
Tue Feb 23 17:28:18 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Feb 23 17:24:53 2010 +0100| [544625f19e2bcff397f6b591759f486d0a325075] | committer: Jakob Leben
a macro to automate the choice of "folder"/"directory" string version according to platform
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=544625f19e2bcff397f6b591759f486d0a325075
---
include/vlc_intf_strings.h | 27 ++++++++++++++++---
modules/gui/qt4/components/open_panels.cpp | 6 +++-
.../gui/qt4/components/playlist/playlist_model.cpp | 16 ++++++++---
modules/gui/qt4/components/preferences_widgets.cpp | 3 +-
modules/gui/qt4/components/sout/sout_widgets.cpp | 6 +++-
modules/gui/qt4/dialogs/help.cpp | 2 +-
modules/gui/qt4/dialogs_provider.cpp | 4 ++-
modules/gui/qt4/menus.cpp | 4 +-
modules/gui/qt4/menus.hpp | 7 -----
9 files changed, 51 insertions(+), 24 deletions(-)
diff --git a/include/vlc_intf_strings.h b/include/vlc_intf_strings.h
index 7609f95..9f6367f 100644
--- a/include/vlc_intf_strings.h
+++ b/include/vlc_intf_strings.h
@@ -29,13 +29,26 @@
* This file defines a number of strings used in user interfaces
*/
+/* A helper macro that will expand to either of the arguments
+ depanding on platform. The arguments are supposed to be:
+ 1. dir: a string containing "directory"
+ 2. folder: a string with the same meaning but with directory
+ substituted with "folder"
+*/
+#if defined( WIN32 ) || defined(__APPLE__)
+ #define I_DIR_OR_FOLDER( dir, folder ) folder
+#else
+ #define I_DIR_OR_FOLDER( dir, folder ) dir
+#endif
+
/*************** Open dialogs **************/
#define I_OP_OPF N_("Quick &Open File...")
#define I_OP_ADVOP N_("&Advanced Open...")
-#define I_OP_OPDIR N_("Open &Directory...")
-
+#define I_OP_OPDIR I_DIR_OR_FOLDER( N_("Open D&irectory..."), \
+ N_("Open &Folder...") )
#define I_OP_SEL_FILES N_("Select one or more files to open")
+#define I_OP_SEL_DIR I_DIR_OR_FOLDER( N_("Select Directory"), N_("Select Folder") )
/******************* Menus *****************/
@@ -54,10 +67,13 @@
#define I_POP_DEL N_("Delete")
#define I_POP_INFO N_("Information...")
#define I_POP_SORT N_("Sort")
-#define I_POP_NEWFOLDER N_("Create Folder...")
+#define I_POP_NEWFOLDER I_DIR_OR_FOLDER( N_("Create Directory..."), \
+ N_("Create Folder...") )
+#define I_POP_EXPLORE I_DIR_OR_FOLDER( N_("Show Containing Directory..."), \
+ N_("Show Containing Folder...") )
#define I_POP_STREAM N_("Stream...")
#define I_POP_SAVE N_("Save...")
-#define I_POP_EXPLORE N_("Show Containing Folder...")
+
/*************** Playlist *************/
@@ -73,7 +89,8 @@
#define I_PL_ADDF N_("Add File...")
#define I_PL_ADVADD N_("Advanced Open...")
-#define I_PL_ADDDIR N_("Add Folder...")
+#define I_PL_ADDDIR I_DIR_OR_FOLDER( N_("Add Directory..."), \
+ N_("Add Folder...") )
#define I_PL_SAVE N_("Save Playlist to &File...")
#define I_PL_LOAD N_("Open Play&list...")
diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index dea7827..7593a84 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -35,6 +35,7 @@
#include "dialogs/open.hpp"
#include "dialogs_provider.hpp" /* Open Subtitle file */
#include "util/qt_dirs.hpp"
+#include <vlc_intf_strings.h>
#include <QFileDialog>
#include <QDialogButtonBox>
@@ -47,7 +48,10 @@
#include <QUrl>
#include <QStringListModel>
-#define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
+
+#define I_DEVICE_TOOLTIP \
+ I_DIR_OR_FOLDER( N_("Select a device or a VIDEO_TS directory"), \
+ N_("Select a device or a VIDEO_TS folder") )
static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
"dshow", "screen", "jack" };
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 8345c0e..39f1034 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -42,9 +42,19 @@
#include <QMenu>
#include <QApplication>
#include <QSettings>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDesktopServices>
+#include <QInputDialog>
#include "sorting.h"
+#define I_NEW_DIR \
+ I_DIR_OR_FOLDER( N_("Create Directory"), N_( "Create Folder" ) )
+#define I_NEW_DIR_NAME \
+ I_DIR_OR_FOLDER( N_( "Enter name for new directory:" ), \
+ N_( "Enter name for new folder:" ) )
+
QIcon PLModel::icons[ITEM_TYPE_NUMBER];
/*************************************************************************
@@ -993,9 +1003,6 @@ void PLModel::popupSave()
THEDP->streamingDialog( NULL, mrls[0] );
}
-#include <QUrl>
-#include <QFileInfo>
-#include <QDesktopServices>
void PLModel::popupExplore()
{
PL_LOCK;
@@ -1028,12 +1035,11 @@ void PLModel::popupExplore()
PL_UNLOCK;
}
-#include <QInputDialog>
void PLModel::popupAddNode()
{
bool ok;
QString name = QInputDialog::getText( PlaylistDialog::getInstance( p_intf ),
- qtr( "Create Folder" ), qtr( "Enter name for new folder:" ),
+ qtr( I_NEW_DIR ), qtr( I_NEW_DIR_NAME ),
QLineEdit::Normal, QString(), &ok);
if( !ok || name.isEmpty() ) return;
PL_LOCK;
diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index a7eac99..4f9f21f 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -38,6 +38,7 @@
#include "util/customwidgets.hpp"
#include "util/qt_dirs.hpp"
#include <vlc_keys.h>
+#include <vlc_intf_strings.h>
#include <QString>
#include <QVariant>
@@ -357,7 +358,7 @@ DirectoryConfigControl::DirectoryConfigControl( vlc_object_t *_p_this,
void DirectoryConfigControl::updateField()
{
QString dir = QFileDialog::getExistingDirectory( NULL,
- qtr( "Select Directory" ),
+ qtr( I_OP_SEL_DIR ),
text->text().isEmpty() ?
QVLCUserDir( VLC_HOME_DIR ) : text->text(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
diff --git a/modules/gui/qt4/components/sout/sout_widgets.cpp b/modules/gui/qt4/components/sout/sout_widgets.cpp
index 799fc08..3be195c 100644
--- a/modules/gui/qt4/components/sout/sout_widgets.cpp
+++ b/modules/gui/qt4/components/sout/sout_widgets.cpp
@@ -27,6 +27,7 @@
#include "components/sout/sout_widgets.hpp"
#include "dialogs/sout.hpp"
#include "util/qt_dirs.hpp"
+#include <vlc_intf_strings.h>
#include <QGroupBox>
#include <QGridLayout>
@@ -34,6 +35,9 @@
#include <QLineEdit>
#include <QFileDialog>
+#define I_FILE_SLASH_DIR \
+ I_DIR_OR_FOLDER( N_("File/Directory"), N_("File/Folder") )
+
SoutInputBox::SoutInputBox( QWidget *_parent, const QString& mrl ) : QGroupBox( _parent )
{
/**
@@ -72,7 +76,7 @@ void SoutInputBox::setMRL( const QString& mrl )
type = mrl.left( i );
}
else
- type = qtr( "File/Directory" );
+ type = qtr( I_FILE_SLASH_DIR );
sourceValueLabel->setText( type );
}
diff --git a/modules/gui/qt4/dialogs/help.cpp b/modules/gui/qt4/dialogs/help.cpp
index 73cdf96..9a56d0e 100644
--- a/modules/gui/qt4/dialogs/help.cpp
+++ b/modules/gui/qt4/dialogs/help.cpp
@@ -268,7 +268,7 @@ void UpdateDialog::UpdateOrDownload()
else
{
QString dest_dir = QFileDialog::getExistingDirectory( this,
- qtr( "Select a directory..." ),
+ qtr( I_OP_SEL_DIR ),
QVLCUserDir( VLC_DOWNLOAD_DIR ) );
if( !dest_dir.isEmpty() )
diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index 8156039..0c6cfdf 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -61,6 +61,8 @@
#include <QSignalMapper>
#include <QFileDialog>
+#define I_OP_DIR_WINTITLE I_DIR_OR_FOLDER( N_("Open Directory"), \
+ N_("Open Folder") )
DialogsProvider* DialogsProvider::instance = NULL;
@@ -488,7 +490,7 @@ void DialogsProvider::openUrlDialog()
**/
static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
{
- QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory"), p_intf->p_sys->filepath );
+ QString dir = QFileDialog::getExistingDirectory( NULL, qtr( I_OP_DIR_WINTITLE ), p_intf->p_sys->filepath );
if (!dir.isEmpty() )
{
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 2f5a016..52264d5 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -313,7 +313,7 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
- addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ),
+ addDPStaticEntry( menu, qtr( I_OP_OPDIR ),
":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
addDPStaticEntry( menu, qtr( "Open &Disc..." ),
":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
@@ -853,7 +853,7 @@ void QVLCMenu::PopupMenuStaticEntries( QMenu *menu )
QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
addDPStaticEntry( openmenu, qtr( "&Open File..." ),
":/type/file-asym", SLOT( openFileDialog() ) );
- addDPStaticEntry( openmenu, qtr( I_OPEN_FOLDER ),
+ addDPStaticEntry( openmenu, qtr( I_OP_OPDIR ),
":/type/folder-grey", SLOT( PLOpenDir() ) );
addDPStaticEntry( openmenu, qtr( "Open &Disc..." ),
":/type/disc", SLOT( openDiscDialog() ) );
diff --git a/modules/gui/qt4/menus.hpp b/modules/gui/qt4/menus.hpp
index 9fa4f58..3d86a98 100644
--- a/modules/gui/qt4/menus.hpp
+++ b/modules/gui/qt4/menus.hpp
@@ -31,13 +31,6 @@
#include <QAction>
#include <vector>
-/* Folder vs. Directory */
-#if defined( WIN32 ) || defined(__APPLE__)
-#define I_OPEN_FOLDER N_("Open &Folder...")
-#else
-#define I_OPEN_FOLDER N_("Open D&irectory...")
-#endif //WIN32
-
using namespace std;
class QMenu;
More information about the vlc-devel
mailing list