Example #1
0
KFilePlacesModel::KFilePlacesModel(QObject *parent)
    : QAbstractItemModel(parent), d(new Private(this))
{
    const QString file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel";
    d->bookmarkManager = KBookmarkManager::managerForExternalFile(file);

    // Let's put some places in there if it's empty.
    KBookmarkGroup root = d->bookmarkManager->root();
    if (root.first().isNull() || !QFile::exists(file)) {

        // NOTE: The context for these I18N_NOOP2 calls has to be "KFile System Bookmarks".
        // The real i18nc call is made later, with this context, so the two must match.
        //
        // createSystemBookmark actually does nothing with its third argument,
        // but we have to give it something so the I18N_NOOP2 calls stay here for now.
        //
        // (coles, 13th May 2009)

        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              QStringLiteral("Home"), I18N_NOOP2("KFile System Bookmarks", "Home"),
                                              QUrl::fromLocalFile(QDir::homePath()), QStringLiteral("user-home"));
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              QStringLiteral("Network"), I18N_NOOP2("KFile System Bookmarks", "Network"),
                                              QUrl(QStringLiteral("remote:/")), QStringLiteral("network-workgroup"));
#if defined(_WIN32_WCE)
        // adding drives
        foreach (const QFileInfo &info, QDir::drives()) {
            QString driveIcon = "drive-harddisk";
            KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                                  info.absoluteFilePath(), info.absoluteFilePath(),
                                                  QUrl::fromLocalFile(info.absoluteFilePath()), driveIcon);
        }
Example #2
0
QString TagRenamerOptions::tagTypeText(TagType type, bool translate)
{
    const char *msg = 0, *context = 0;

    switch(type) {
        case Title:
            msg = I18N_NOOP2("song title", "Title");
            context = "song title";
        break;

        case Artist:
            msg = I18N_NOOP("Artist");
        break;

        case Album:
            msg = I18N_NOOP("Album");
        break;

        case Track:
            msg = I18N_NOOP2("cd track number", "Track");
            context = "cd track number";
        break;

        case Genre:
            msg = I18N_NOOP("Genre");
        break;

        case Year:
            msg = I18N_NOOP("Year");
        break;

        default:
            kWarning() << "I don't know what category we're looking up, this is a problem.";
            kWarning() << "The category ID is " << (unsigned) type;
            msg = I18N_NOOP2("unknown renamer category", "Unknown");
            context = "unknown renamer category";
    }

    if(translate)
        return context ? i18nc(context, msg) : i18n(msg);
    else
        return msg;
}
Example #3
0
KFilePlacesModel::KFilePlacesModel(QObject *parent)
    : QAbstractItemModel(parent), d(new Private(this))
{
    const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
    d->bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");

    // Let's put some places in there if it's empty. We have a corner case here:
    // Given you have bookmarked some folders (which have been saved on
    // ~/.local/share/user-places.xbel (according to freedesktop bookmarks spec), and
    // deleted the home directory ~/.kde, the call managerForFile() will return the
    // bookmark manager for the fallback "kfilePlaces", making root.first().isNull() being
    // false (you have your own items bookmarked), resulting on only being added your own
    // bookmarks, and not the default ones too. So, we also check if kfileplaces/bookmarks.xml
    // file exists, and if it doesn't, we also add the default places. (ereslibre)
    KBookmarkGroup root = d->bookmarkManager->root();
    if (root.first().isNull() || !QFile::exists(file)) {

        // NOTE: The context for these I18N_NOOP2 calls has to be "KFile System Bookmarks".
        // The real i18nc call is made later, with this context, so the two must match.
        //
        // createSystemBookmark actually does nothing with its third argument,
        // but we have to give it something so the I18N_NOOP2 calls stay here for now.
        //
        // (coles, 13th May 2009)

        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Home", I18N_NOOP2("KFile System Bookmarks", "Home"),
                                              KUrl(KUser().homeDir()), "user-home");
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Network", I18N_NOOP2("KFile System Bookmarks", "Network"),
                                              KUrl("remote:/"), "network-workgroup");
#ifdef Q_OS_WIN
        // adding drives
        foreach ( const QFileInfo& info, QDir::drives() ) {
#ifndef _WIN32_WCE
            uint type = DRIVE_UNKNOWN;
#endif
            QString driveIcon = "drive-harddisk";
#ifndef _WIN32_WCE
            QT_WA({ type = GetDriveTypeW((wchar_t *)info.absoluteFilePath().utf16()); },
                  { type = GetDriveTypeA(info.absoluteFilePath().toLocal8Bit()); });
Example #4
0
{
        int tag;
        const char *str;
} MAPI_TagStrings[] =
{
        { 0x0002, I18N_NOOP( "Alternate Recipient Allowed" ) },
        { 0x001A, I18N_NOOP( "Message Class" ) },
        { 0x0023, I18N_NOOP( "Originator Delivery Report Requested" ) },
        { 0x0024, I18N_NOOP( "Originator Return Address" ) },
        { 0x0026, I18N_NOOP( "Priority" ) },
        { 0x0029, I18N_NOOP( "Read Receipt Requested" ) },
        { 0x002B, I18N_NOOP( "Recipient Reassignment Prohibited" ) },
        { 0x002E, I18N_NOOP( "Original Sensitivity" ) },
        { 0x0031, I18N_NOOP( "Report Tag" ) },
        { 0x0036, I18N_NOOP( "Sensitivity" ) },
        { 0x0037, I18N_NOOP2( "@label The subject of an email", "Subject" ) },
        { 0x0039, I18N_NOOP( "Client Submit Time" ) },
        { 0x003B, I18N_NOOP( "Sent Representing Search Key" ) },
        { 0x003D, I18N_NOOP( "Subject Prefix" ) },
        { 0x0041, I18N_NOOP( "Sent Representing Entry ID" ) },
        { 0x0042, I18N_NOOP( "Sent Representing Name" ) },
        { 0x0047, I18N_NOOP( "Message Submission ID" ) },
        { 0x004D, I18N_NOOP( "Original Author Name" ) },
        { 0x0062, I18N_NOOP( "Owner Appointment ID" ) },
        { 0x0063, I18N_NOOP( "Response Requested" ) },
        { 0x0064, I18N_NOOP( "Sent Representing Address Type" ) },
        { 0x0065, I18N_NOOP( "Sent Representing E-mail Address" ) },
        { 0x0070, I18N_NOOP( "Conversation Topic" ) },
        { 0x0071, I18N_NOOP( "Conversation Index" ) },
        { 0x007F, I18N_NOOP( "TNEF Correlation Key" ) },
        { 0x0C17, I18N_NOOP( "Reply Requested" ) },
Example #5
0
QString KSUtils::toDirectionString( dms angle ) {
    // TODO: Instead of doing it this way, it would be nicer to
    // compute the string to arbitrary precision. Although that will
    // not be easy to localize.  (Consider, for instance, Indian
    // languages that have special names for the intercardinal points)
    // -- asimha

    static const char *directions[] = {
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "N"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NNE"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NE"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "ENE"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "E"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "ESE"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SE"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SSE"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "S"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SSW"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SW"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "WSW"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "W"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "WNW"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NW"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NNW"),
        I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "N"),
    };

    int index = (int)( (angle.Degrees() + 11.25) / 22.5); // A number between 0 and 16 (inclusive), 16 meaning the same thing as zero.

    return i18nc( "Abbreviated cardinal / intercardinal etc. direction", directions[ index ] );
}
// other Qt includes:
#include <QLabel>
#include <QLayout>
#include <QGridLayout>
#include <QByteArray>
#include <QCheckBox>

// other includes:
#include <assert.h>

static const struct {
  KMMsgPartDialog::Encoding encoding;
  const char * displayName;
} encodingTypes[] = {
  { KMMsgPartDialog::SevenBit, I18N_NOOP2("message encoding type", "None (7-bit text)") },
  { KMMsgPartDialog::EightBit, I18N_NOOP2("message encoding type", "None (8-bit text)") },
  { KMMsgPartDialog::QuotedPrintable, I18N_NOOP2("message encoding type", "Quoted Printable") },
  { KMMsgPartDialog::Base64, I18N_NOOP2("message encoding type", "Base 64") },
};
static const int numEncodingTypes =
  sizeof encodingTypes / sizeof *encodingTypes;

KMMsgPartDialog::KMMsgPartDialog( const QString & caption,
                                  QWidget * parent )
  : KDialog( parent )
{
  setCaption( caption.isEmpty() ? i18n("Message Part Properties") : caption );
  setButtons( Ok|Cancel|Help );
  setDefaultButton( Ok );
  setModal( true );
Example #7
0
                                              "Home", I18N_NOOP2("KFile System Bookmarks", "Home"),
                                              KUrl(KUser().homeDir()), "user-home");
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Network", I18N_NOOP2("KFile System Bookmarks", "Network"),
                                              KUrl("remote:/"), "network-workgroup");
#if defined(_WIN32_WCE)
        // adding drives
        foreach ( const QFileInfo& info, QDir::drives() ) {
            QString driveIcon = "drive-harddisk";
            KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                                  info.absoluteFilePath(), info.absoluteFilePath(),
                                                  KUrl(info.absoluteFilePath()), driveIcon);
        }
#elif !defined(Q_OS_WIN)
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Root", I18N_NOOP2("KFile System Bookmarks", "Root"),
                                              KUrl("/"), "folder-red");
#endif
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              "Trash", I18N_NOOP2("KFile System Bookmarks", "Trash"),
                                              KUrl("trash:/"), "user-trash");

        // Force bookmarks to be saved. If on open/save dialog and the bookmarks are not saved, QFile::exists
        // will always return false, which opening/closing all the time the open/save dialog would case the
        // bookmarks to be added once each time, having lots of times each bookmark. This forces the defaults
        // to be saved on the bookmarks.xml file. Of course, the complete list of bookmarks (those that come from
        // user-places.xbel will be filled later). (ereslibre)
        d->bookmarkManager->saveAs(file);
    }

    // create after, so if we have own places, they are added afterwards, in case of equal priorities
Example #8
0
QString InlineTag::displayName() const
{
    static const char* inlineElementNames[(int)InlineElementCount]={
        "_unknown",
        I18N_NOOP2("XLIFF inline tag name", "Start of paired tag"),
        I18N_NOOP2("XLIFF inline tag name", "End of paired tag"),
        I18N_NOOP2("XLIFF inline tag name", "Stand-alone tag"),
        I18N_NOOP2("XLIFF inline tag name", "Isolated tag"),
        //"_NEVERSHOULDBECHOSEN",
        I18N_NOOP2("XLIFF inline tag name", "Marker"),
        I18N_NOOP2("XLIFF inline tag name", "Generic group placeholder"),
        I18N_NOOP2("XLIFF inline tag name", "Sub-flow"),
        "_NEVERSHOULDBECHOSEN",
        I18N_NOOP2("XLIFF inline tag name", "Generic placeholder"),
        I18N_NOOP2("XLIFF inline tag name", "Start of paired placeholder"),
        I18N_NOOP2("XLIFF inline tag name", "End of paired placeholder")
    };

    QString result=i18nc("XLIFF inline tag name", inlineElementNames[type]);

    if (type==mrk)
    {
        static const char* mrkTypes[]={
            "abbrev",
            "abbreviated-form",
            "abbreviation",
            "acronym",
            "appellation",
            "collocation",
            "common-name",
            "datetime",
            "equation",
            "expanded-form",
            "formula",
            "head-term",
            "initialism",
            "international-scientific-term",
            "internationalism",
            "logical-expression",
            "materials-management-unit",
            "name",
            "near-synonym",
            "part-number",
            "phrase",
            "phraseological-unit",
            "protected",
            "romanized-form",
            "seg",
            "set-phrase",
            "short-form",
            "sku",
            "standard-text",
            "symbol",
            "synonym",
            "synonymous-phrase",
            "term",
            "transcribed-form",
            "transliterated-form",
            "truncated-term",
            "variant"
        };

        static const char* mrkTypeNames[]={
            I18N_NOOP2("XLIFF mark type", "abbreviation"),
            I18N_NOOP2("XLIFF mark type", "abbreviated form: a term resulting from the omission of any part of the full term while designating the same concept"),
            I18N_NOOP2("XLIFF mark type", "abbreviation: an abbreviated form of a simple term resulting from the omission of some of its letters (e.g. 'adj.' for 'adjective')"),
            I18N_NOOP2("XLIFF mark type", "acronym: an abbreviated form of a term made up of letters from the full form of a multiword term strung together into a sequence pronounced only syllabically (e.g. 'radar' for 'radio detecting and ranging')"),
            I18N_NOOP2("XLIFF mark type", "appellation: a proper-name term, such as the name of an agency or other proper entity"),
            I18N_NOOP2("XLIFF mark type", "collocation: a recurrent word combination characterized by cohesion in that the components of the collocation must co-occur within an utterance or series of utterances, even though they do not necessarily have to maintain immediate proximity to one another"),
            I18N_NOOP2("XLIFF mark type", "common name: a synonym for an international scientific term that is used in general discourse in a given language"),
            I18N_NOOP2("XLIFF mark type", "date and/or time"),
            I18N_NOOP2("XLIFF mark type", "equation: an expression used to represent a concept based on a statement that two mathematical expressions are, for instance, equal as identified by the equal sign (=), or assigned to one another by a similar sign"),
            I18N_NOOP2("XLIFF mark type", "expanded form: The complete representation of a term for which there is an abbreviated form"),
            I18N_NOOP2("XLIFF mark type", "formula: figures, symbols or the like used to express a concept briefly, such as a mathematical or chemical formula"),
            I18N_NOOP2("XLIFF mark type", "head term: the concept designation that has been chosen to head a terminological record"),
            I18N_NOOP2("XLIFF mark type", "initialism: an abbreviated form of a term consisting of some of the initial letters of the words making up a multiword term or the term elements making up a compound term when these letters are pronounced individually (e.g. 'BSE' for 'bovine spongiform encephalopathy')"),
            I18N_NOOP2("XLIFF mark type", "international scientific term: a term that is part of an international scientific nomenclature as adopted by an appropriate scientific body"),
            I18N_NOOP2("XLIFF mark type", "internationalism: a term that has the same or nearly identical orthographic or phonemic form in many languages"),
            I18N_NOOP2("XLIFF mark type", "logical expression: an expression used to represent a concept based on mathematical or logical relations, such as statements of inequality, set relationships, Boolean operations, and the like"),
            I18N_NOOP2("XLIFF mark type", "materials management unit: a unit to track object"),
            I18N_NOOP2("XLIFF mark type", "name"),
            I18N_NOOP2("XLIFF mark type", "near synonym: a term that represents the same or a very similar concept as another term in the same language, but for which interchangeability is limited to some contexts and inapplicable in others"),
            I18N_NOOP2("XLIFF mark type", "part number: a unique alphanumeric designation assigned to an object in a manufacturing system"),
            I18N_NOOP2("XLIFF mark type", "phrase"),
            I18N_NOOP2("XLIFF mark type", "phraseological: a group of two or more words that form a unit, the meaning of which frequently cannot be deduced based on the combined sense of the words making up the phrase"),
            I18N_NOOP2("XLIFF mark type", "protected: the marked text should not be translated"),
            I18N_NOOP2("XLIFF mark type", "romanized form: a form of a term resulting from an operation whereby non-Latin writing systems are converted to the Latin alphabet"),
            I18N_NOOP2("XLIFF mark type", "segment: the marked text represents a segment"),
            I18N_NOOP2("XLIFF mark type", "set phrase: a fixed, lexicalized phrase"),
            I18N_NOOP2("XLIFF mark type", "short form: a variant of a multiword term that includes fewer words than the full form of the term (e.g. 'Group of Twenty-four' for 'Intergovernmental Group of Twenty-four on International Monetary Affairs')"),
            I18N_NOOP2("XLIFF mark type", "stock keeping unit: an inventory item identified by a unique alphanumeric designation assigned to an object in an inventory control system"),
            I18N_NOOP2("XLIFF mark type", "standard text: a fixed chunk of recurring text"),
            I18N_NOOP2("XLIFF mark type", "symbol: a designation of a concept by letters, numerals, pictograms or any combination thereof"),
            I18N_NOOP2("XLIFF mark type", "synonym: a term that represents the same or a very similar concept as the main entry term in a term entry"),
            I18N_NOOP2("XLIFF mark type", "synonymous phrase: phraseological unit in a language that expresses the same semantic content as another phrase in that same language"),
            I18N_NOOP2("XLIFF mark type", "term"),
            I18N_NOOP2("XLIFF mark type", "transcribed form: a form of a term resulting from an operation whereby the characters of one writing system are represented by characters from another writing system, taking into account the pronunciation of the characters converted"),
            I18N_NOOP2("XLIFF mark type", "transliterated form: a form of a term resulting from an operation whereby the characters of an alphabetic writing system are represented by characters from another alphabetic writing system"),
            I18N_NOOP2("XLIFF mark type", "truncated term: an abbreviated form of a term resulting from the omission of one or more term elements or syllables (e.g. 'flu' for 'influenza')"),
            I18N_NOOP2("XLIFF mark type", "variant: one of the alternate forms of a term")
        };
        int i=sizeof(mrkTypes)/sizeof(char*);
        while(--i>=0 && mrkTypes[i]!=id)
            ;
        if (i!=-1)
        {
            result=i18nc("XLIFF mark type", mrkTypeNames[i]);
            if (!result.isEmpty())
                result[0]=result.at(0).toUpper();
        }
    }
    
    if (!ctype.isEmpty())
        result+=" ("+ctype+")";

    return result;
}
Example #9
0
    KgvFormat format;
    QPrinter::PageSize kprinter;
    const char* shortName; // Short name
    const char* descriptiveName; // Full name, which will be translated
    double width; // in mm
    double height; // in mm
};

// NOTES:
// - the width and height of non-ISO formats are rounded
// http://en.wikipedia.org/wiki/Paper_size can help
// - the comments "should be..." indicates the exact values if the inch sizes would be multiplied by 25.4 mm/inch

const PageFormatInfo pageFormatInfo[]=
{
    { PG_DIN_A3,        QPrinter::A3,           "A3",           I18N_NOOP2("Page size", "ISO A3"),       297.0,  420.0 },
    { PG_DIN_A4,        QPrinter::A4,           "A4",           I18N_NOOP2("Page size", "ISO A4"),       210.0,  297.0 },
    { PG_DIN_A5,        QPrinter::A5,           "A5",           I18N_NOOP2("Page size", "ISO A5"),       148.0,  210.0 },
    { PG_US_LETTER,     QPrinter::Letter,       "Letter",       I18N_NOOP2("Page size", "US Letter"),    215.9,  279.4 },
    { PG_US_LEGAL,      QPrinter::Legal,        "Legal",        I18N_NOOP2("Page size", "US Legal"),     215.9,  355.6 },
    { PG_SCREEN,        QPrinter::A4,           "Screen",       I18N_NOOP2("Page size", "Screen"), PG_A4_HEIGHT, PG_A4_WIDTH }, // Custom, so fall back to A4
    { PG_CUSTOM,        QPrinter::A4,           "Custom",       I18N_NOOP2("Page size", "Custom"), PG_A4_WIDTH, PG_A4_HEIGHT }, // Custom, so fall back to A4
    { PG_DIN_B5,        QPrinter::B5,           "B5",           I18N_NOOP2("Page size", "ISO B5"),       182.0,  257.0 },
    // Hmm, wikipedia says 184.15 * 266.7 for executive !
    { PG_US_EXECUTIVE,  QPrinter::Executive,    "Executive",    I18N_NOOP2("Page size", "US Executive"), 191.0,  254.0 }, // should be 190.5 mm x 254.0 mm
    { PG_DIN_A0,        QPrinter::A0,           "A0",           I18N_NOOP2("Page size", "ISO A0"),       841.0, 1189.0 },
    { PG_DIN_A1,        QPrinter::A1,           "A1",           I18N_NOOP2("Page size", "ISO A1"),       594.0,  841.0 },
    { PG_DIN_A2,        QPrinter::A2,           "A2",           I18N_NOOP2("Page size", "ISO A2"),       420.0,  594.0 },
    { PG_DIN_A6,        QPrinter::A6,           "A6",           I18N_NOOP2("Page size", "ISO A6"),       105.0,  148.0 },
    { PG_DIN_A7,        QPrinter::A7,           "A7",           I18N_NOOP2("Page size", "ISO A7"),        74.0,  105.0 },
    { PG_DIN_A8,        QPrinter::A8,           "A8",           I18N_NOOP2("Page size", "ISO A8"),        52.0,   74.0 },
Example #10
0
namespace KStdAccel {

struct KStdAccelInfo
{
    StdAccel id;
    const char *psName;
    const char *psDesc;
    int cutDefault, cutDefault4, cutDefault3B, cutDefault4B;
    KShortcut cut;
    bool bInitialized;
};

/** Array of predefined KStdAccelInfo objects, which cover all
    the "standard" accelerators. Each enum value from StdAccel
    should appear in this table.
*/
static KStdAccelInfo g_infoStdAccel[] = {
    {AccelNone, "Group:File", I18N_NOOP("File"), 0, 0, 0, 0, KShortcut(), false},
    {Open, I18N_NOOP("Open"), 0, Qt::CTRL + Qt::Key_O, 0, 0, 0, KShortcut(), false},
    {New, I18N_NOOP("New"), 0, Qt::CTRL + Qt::Key_N, 0, 0, 0, KShortcut(), false},
    {Close, I18N_NOOP("Close"), 0, Qt::CTRL + Qt::Key_W, Qt::CTRL + Qt::Key_Escape, 0, Qt::CTRL + Qt::Key_W, KShortcut(), false},
    {Save, I18N_NOOP("Save"), 0, Qt::CTRL + Qt::Key_S, 0, 0, 0, KShortcut(), false},
    {Print, I18N_NOOP("Print"), 0, Qt::CTRL + Qt::Key_P, 0, 0, 0, KShortcut(), false},
    {Quit, I18N_NOOP("Quit"), 0, Qt::CTRL + Qt::Key_Q, 0, 0, 0, KShortcut(), false},
    {AccelNone, "Group:Edit", I18N_NOOP("Edit"), 0, 0, 0, 0, KShortcut(), false},
    {Undo, I18N_NOOP("Undo"), 0, Qt::CTRL + Qt::Key_Z, 0, 0, 0, KShortcut(), false},
    {Redo, I18N_NOOP("Redo"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Z, 0, 0, 0, KShortcut(), false},
    {Cut, I18N_NOOP("Cut"), 0, Qt::CTRL + Qt::Key_X, 0, Qt::SHIFT + Qt::Key_Delete, 0, KShortcut(), false},
    {Copy, I18N_NOOP("Copy"), 0, Qt::CTRL + Qt::Key_C, 0, Qt::CTRL + Qt::Key_Insert, 0, KShortcut(), false},
    {Paste, I18N_NOOP("Paste"), 0, Qt::CTRL + Qt::Key_V, 0, Qt::SHIFT + Qt::Key_Insert, 0, KShortcut(), false},
    {PasteSelection, I18N_NOOP("Paste Selection"), 0, 0, 0, Qt::CTRL + Qt::SHIFT + Qt::Key_Insert, 0, KShortcut(), false},
    {SelectAll, "SelectAll", I18N_NOOP("Select All"), Qt::CTRL + Qt::Key_A, 0, 0, 0, KShortcut(), false},
    {Deselect, I18N_NOOP("Deselect"), 0, Qt::CTRL + Qt::SHIFT + Qt::Key_A, 0, 0, 0, KShortcut(), false},
    {DeleteWordBack, "DeleteWordBack", I18N_NOOP("Delete Word Backwards"), Qt::CTRL + Qt::Key_Backspace, 0, 0, 0, KShortcut(), false},
    {DeleteWordForward, "DeleteWordForward", I18N_NOOP("Delete Word Forward"), Qt::CTRL + Qt::Key_Delete, 0, 0, 0, KShortcut(), false},
    {Find, I18N_NOOP("Find"), 0, Qt::CTRL + Qt::Key_F, 0, 0, 0, KShortcut(), false},
    {FindNext, "FindNext", I18N_NOOP("Find Next"), Qt::Key_F3, 0, 0, 0, KShortcut(), false},
    {FindPrev, "FindPrev", I18N_NOOP("Find Prev"), Qt::SHIFT + Qt::Key_F3, 0, 0, 0, KShortcut(), false},
    {Replace, I18N_NOOP("Replace"), 0, Qt::CTRL + Qt::Key_R, 0, 0, 0, KShortcut(), false},
    {AccelNone, "Group:Navigation", I18N_NOOP("Navigation"), 0, 0, 0, 0, KShortcut(), false},
    {Home, I18N_NOOP2("Opposite to End", "Home"), 0, Qt::CTRL + Qt::Key_Home, 0, Qt::Key_HomePage, 0, KShortcut(), false},
    {End, I18N_NOOP("End"), 0, Qt::CTRL + Qt::Key_End, 0, 0, 0, KShortcut(), false},
    {BeginningOfLine, "BeginningOfLine", I18N_NOOP("Beginning of Line"), Qt::Key_Home, 0, 0, 0, KShortcut(), false},
    {EndOfLine, "EndOfLine", I18N_NOOP("End of Line"), Qt::Key_End, 0, 0, 0, KShortcut(), false},
    {Prior, I18N_NOOP("Prior"), 0, Qt::Key_Prior, 0, 0, 0, KShortcut(), false},
    {Next, I18N_NOOP2("Opposite to Prior", "Next"), 0, Qt::Key_Next, 0, 0, 0, KShortcut(), false},
    {GotoLine, "GotoLine", I18N_NOOP("Go to Line"), Qt::CTRL + Qt::Key_G, 0, 0, 0, KShortcut(), false},
    {AddBookmark, "AddBookmark", I18N_NOOP("Add Bookmark"), Qt::CTRL + Qt::Key_B, 0, 0, 0, KShortcut(), false},
    {ZoomIn, "ZoomIn", I18N_NOOP("Zoom In"), Qt::CTRL + Qt::Key_Plus, 0, 0, 0, KShortcut(), false},
    {ZoomOut, "ZoomOut", I18N_NOOP("Zoom Out"), Qt::CTRL + Qt::Key_Minus, 0, 0, 0, KShortcut(), false},
    {Up, I18N_NOOP("Up"), 0, Qt::ALT + Qt::Key_Up, 0, 0, 0, KShortcut(), false},
    {Back, I18N_NOOP("Back"), 0, Qt::ALT + Qt::Key_Left, 0, Qt::Key_Back, 0, KShortcut(), false},
    {Forward, I18N_NOOP("Forward"), 0, Qt::ALT + Qt::Key_Right, 0, Qt::Key_Forward, 0, KShortcut(), false},
    {Reload, I18N_NOOP("Reload"), 0, Qt::Key_F5, 0, Qt::Key_Refresh, 0, KShortcut(), false},
    {PopupMenuContext, "PopupMenuContext", I18N_NOOP("Popup Menu Context"), Qt::Key_Menu, 0, 0, 0, KShortcut(), false},
    {ShowMenubar, "ShowMenubar", I18N_NOOP("Show Menu Bar"), Qt::CTRL + Qt::Key_M, 0, 0, 0, KShortcut(), false},
    {BackwardWord, "BackwardWord", I18N_NOOP("Backward Word"), Qt::CTRL + Qt::Key_Left, 0, 0, 0, KShortcut(), false},
    {ForwardWord, "ForwardWord", I18N_NOOP("Forward Word"), Qt::CTRL + Qt::Key_Right, 0, 0, 0, KShortcut(), false},
    {TabNext, I18N_NOOP("Activate Next Tab"), 0, Qt::CTRL + Qt::Key_Period, 0, Qt::CTRL + Qt::Key_BracketRight, 0, KShortcut(), false},
    {TabPrev, I18N_NOOP("Activate Previous Tab"), 0, Qt::CTRL + Qt::Key_Comma, 0, Qt::CTRL + Qt::Key_BracketLeft, 0, KShortcut(), false},
    {FullScreen, "FullScreen", I18N_NOOP("Full Screen Mode"), Qt::CTRL + Qt::SHIFT + Qt::Key_F, 0, 0, 0, KShortcut(), false},
    {AccelNone, "Group:Help", I18N_NOOP("Help"), 0, 0, 0, 0, KShortcut(), false},
    {Help, I18N_NOOP("Help"), 0, Qt::Key_F1, 0, 0, 0, KShortcut(), false},
    {WhatsThis, "WhatsThis", I18N_NOOP("What's This"), Qt::SHIFT + Qt::Key_F1, 0, 0, 0, KShortcut(), false},
    {AccelNone, "Group:TextCompletion", I18N_NOOP("Text Completion"), 0, 0, 0, 0, KShortcut(), false},
    {TextCompletion, "TextCompletion", I18N_NOOP("Text Completion"), Qt::CTRL + Qt::Key_E, 0, 0, 0, KShortcut(), false},
    {PrevCompletion, "PrevCompletion", I18N_NOOP("Previous Completion Match"), Qt::CTRL + Qt::Key_Up, 0, 0, 0, KShortcut(), false},
    {NextCompletion, "NextCompletion", I18N_NOOP("Next Completion Match"), Qt::CTRL + Qt::Key_Down, 0, 0, 0, KShortcut(), false},
    {SubstringCompletion, "SubstringCompletion", I18N_NOOP("Substring Completion"), Qt::CTRL + Qt::Key_T, 0, 0, 0, KShortcut(), false},
    {RotateUp, "RotateUp", I18N_NOOP("Previous Item in List"), Qt::Key_Up, 0, 0, 0, KShortcut(), false},
    {RotateDown, "RotateDown", I18N_NOOP("Next Item in List"), Qt::Key_Down, 0, 0, 0, KShortcut(), false},
    {AccelNone, 0, 0, 0, 0, 0, 0, KShortcut(), false}};

/** Search for the KStdAccelInfo object associated with the given @p id. */
static KStdAccelInfo *infoPtr(StdAccel id)
{
    if(id != AccelNone)
    {
        // Linear search. Changing the data structure doesn't seem possible
        // (since we need groups for the config stuff), but maybe a little
        // additional hashtable wouldn't hurt.
        for(uint i = 0; g_infoStdAccel[i].psName != 0; i++)
        {
            if(g_infoStdAccel[i].id == id)
                return &g_infoStdAccel[i];
        }
    }
    return 0;
}

/** Initialize the accelerator @p id by checking if it is overridden
    in the configuration file (and if it isn't, use the default).
*/
static void initialize(StdAccel id)
{
    KConfigGroupSaver saver(KGlobal::config(), "Shortcuts");
    KStdAccelInfo *pInfo = infoPtr(id);

    if(!pInfo)
    {
        kdWarning(125) << "KStdAccel: id not found!" << endl; // -- ellis
        return;
    }

    if(saver.config()->hasKey(pInfo->psName))
    {
        QString s = saver.config()->readEntry(pInfo->psName);
        if(s != "none")
            pInfo->cut.init(s);
        else
            pInfo->cut.clear();
    }
    else
        pInfo->cut = shortcutDefault(id);
    pInfo->bInitialized = true;
}

QString name(StdAccel id)
{
    KStdAccelInfo *pInfo = infoPtr(id);
    if(!pInfo)
        return QString::null;
    return pInfo->psName;
}

QString label(StdAccel id)
{
    KStdAccelInfo *pInfo = infoPtr(id);
    if(!pInfo)
        return QString::null;
    return i18n((pInfo->psDesc) ? pInfo->psDesc : pInfo->psName);
}

// TODO: Add psWhatsThis entry to KStdAccelInfo
QString whatsThis(StdAccel /*id*/)
{
    //	KStdAccelInfo* pInfo = infoPtr( id );
    //	if( pInfo && pInfo->psWhatsThis )
    //		return i18n(pInfo->psWhatsThis);
    //	else
    return QString::null;
}

const KShortcut &shortcut(StdAccel id)
{
    KStdAccelInfo *pInfo = infoPtr(id);
    if(!pInfo)
        return KShortcut::null();

    if(!pInfo->bInitialized)
        initialize(id);

    return pInfo->cut;
}

StdAccel findStdAccel(const KKeySequence &seq)
{
    if(!seq.isNull())
    {
        for(uint i = 0; g_infoStdAccel[i].psName != 0; i++)
        {
            StdAccel id = g_infoStdAccel[i].id;
            if(id != AccelNone)
            {
                if(!g_infoStdAccel[i].bInitialized)
                    initialize(id);
                if(g_infoStdAccel[i].cut.contains(seq))
                    return id;
            }
        }
    }
    return AccelNone;
}

KShortcut shortcutDefault(StdAccel id)
{
    return (KAccelAction::useFourModifierKeys()) ? shortcutDefault4(id) : shortcutDefault3(id);
}

KShortcut shortcutDefault3(StdAccel id)
{
    KShortcut cut;

    KStdAccelInfo *pInfo = infoPtr(id);
    if(pInfo)
    {
        if(pInfo->cutDefault)
            cut.init(pInfo->cutDefault);
        // FIXME: if there is no cutDefault, then this we be made the primary
        //  instead of alternate shortcut.
        if(pInfo->cutDefault3B)
            cut.append(KKey(pInfo->cutDefault3B));
    }

    return cut;
}

KShortcut shortcutDefault4(StdAccel id)
{
    KShortcut cut;

    KStdAccelInfo *pInfo = infoPtr(id);
    if(pInfo)
    {
        KStdAccelInfo &info = *pInfo;
        KKeySequence key2;

        cut.init((info.cutDefault4) ? QKeySequence(info.cutDefault) : QKeySequence(info.cutDefault4));

        if(info.cutDefault4B)
            key2.init(QKeySequence(info.cutDefault4B));
        else if(info.cutDefault3B)
            key2.init(QKeySequence(info.cutDefault3B));

        if(key2.count())
            cut.append(key2);
    }

    return cut;
}

#if 0 // unused
void createAccelActions( KAccelActions& actions )
{
	actions.clear();

	for( uint i = 0; g_infoStdAccel[i].psName != 0; i++ ) {
		StdAccel id = g_infoStdAccel[i].id;
		KStdAccelInfo* pInfo = &g_infoStdAccel[i];

		if( id != AccelNone ) {
			actions.insert( pInfo->psName,
				i18n((pInfo->psDesc) ? pInfo->psDesc : pInfo->psName),
				QString::null, // pInfo->psWhatsThis,
				shortcutDefault3(id),
				shortcutDefault4(id) );
		} else
			actions.insert( pInfo->psName, i18n(pInfo->psDesc) );
	}
}
#endif

const KShortcut &open()
{
    return shortcut(Open);
}
const KShortcut &openNew()
{
    return shortcut(New);
}
const KShortcut &close()
{
    return shortcut(Close);
}
const KShortcut &save()
{
    return shortcut(Save);
}
const KShortcut &print()
{
    return shortcut(Print);
}
const KShortcut &quit()
{
    return shortcut(Quit);
}
const KShortcut &cut()
{
    return shortcut(Cut);
}
const KShortcut &copy()
{
    return shortcut(Copy);
}
const KShortcut &paste()
{
    return shortcut(Paste);
}
const KShortcut &pasteSelection()
{
    return shortcut(PasteSelection);
}
const KShortcut &deleteWordBack()
{
    return shortcut(DeleteWordBack);
}
const KShortcut &deleteWordForward()
{
    return shortcut(DeleteWordForward);
}
const KShortcut &undo()
{
    return shortcut(Undo);
}
const KShortcut &redo()
{
    return shortcut(Redo);
}
const KShortcut &find()
{
    return shortcut(Find);
}
const KShortcut &findNext()
{
    return shortcut(FindNext);
}
const KShortcut &findPrev()
{
    return shortcut(FindPrev);
}
const KShortcut &replace()
{
    return shortcut(Replace);
}
const KShortcut &home()
{
    return shortcut(Home);
}
const KShortcut &end()
{
    return shortcut(End);
}
const KShortcut &beginningOfLine()
{
    return shortcut(BeginningOfLine);
}
const KShortcut &endOfLine()
{
    return shortcut(EndOfLine);
}
const KShortcut &prior()
{
    return shortcut(Prior);
}
const KShortcut &next()
{
    return shortcut(Next);
}
const KShortcut &backwardWord()
{
    return shortcut(BackwardWord);
}
const KShortcut &forwardWord()
{
    return shortcut(ForwardWord);
}
const KShortcut &gotoLine()
{
    return shortcut(GotoLine);
}
const KShortcut &addBookmark()
{
    return shortcut(AddBookmark);
}
const KShortcut &tabNext()
{
    return shortcut(TabNext);
}
const KShortcut &tabPrev()
{
    return shortcut(TabPrev);
}
const KShortcut &fullScreen()
{
    return shortcut(FullScreen);
}
const KShortcut &zoomIn()
{
    return shortcut(ZoomIn);
}
const KShortcut &zoomOut()
{
    return shortcut(ZoomOut);
}
const KShortcut &help()
{
    return shortcut(Help);
}
const KShortcut &completion()
{
    return shortcut(TextCompletion);
}
const KShortcut &prevCompletion()
{
    return shortcut(PrevCompletion);
}
const KShortcut &nextCompletion()
{
    return shortcut(NextCompletion);
}
const KShortcut &rotateUp()
{
    return shortcut(RotateUp);
}
const KShortcut &rotateDown()
{
    return shortcut(RotateDown);
}
const KShortcut &substringCompletion()
{
    return shortcut(SubstringCompletion);
}
const KShortcut &popupMenuContext()
{
    return shortcut(PopupMenuContext);
}
const KShortcut &whatsThis()
{
    return shortcut(WhatsThis);
}
const KShortcut &reload()
{
    return shortcut(Reload);
}
const KShortcut &selectAll()
{
    return shortcut(SelectAll);
}
const KShortcut &up()
{
    return shortcut(Up);
}
const KShortcut &back()
{
    return shortcut(Back);
}
const KShortcut &forward()
{
    return shortcut(Forward);
}
const KShortcut &showMenubar()
{
    return shortcut(ShowMenubar);
}

//---------------------------------------------------------------------
// ShortcutList
//---------------------------------------------------------------------

ShortcutList::ShortcutList()
{
}

ShortcutList::~ShortcutList()
{
}

uint ShortcutList::count() const
{
    static uint g_nAccels = 0;
    if(g_nAccels == 0)
    {
        for(; g_infoStdAccel[g_nAccels].psName != 0; g_nAccels++)
            ;
    }
    return g_nAccels;
}

QString ShortcutList::name(uint i) const
{
    return g_infoStdAccel[i].psName;
}

QString ShortcutList::label(uint i) const
{
    return i18n((g_infoStdAccel[i].psDesc) ? g_infoStdAccel[i].psDesc : g_infoStdAccel[i].psName);
}

QString ShortcutList::whatsThis(uint) const
{
    return QString::null;
}

const KShortcut &ShortcutList::shortcut(uint i) const
{
    if(!g_infoStdAccel[i].bInitialized)
        initialize(g_infoStdAccel[i].id);
    return g_infoStdAccel[i].cut;
}

const KShortcut &ShortcutList::shortcutDefault(uint i) const
{
    static KShortcut cut;
    cut = KStdAccel::shortcutDefault(g_infoStdAccel[i].id);
    return cut;
}

bool ShortcutList::isConfigurable(uint i) const
{
    return (g_infoStdAccel[i].id != AccelNone);
}

bool ShortcutList::setShortcut(uint i, const KShortcut &cut)
{
    g_infoStdAccel[i].cut = cut;
    return true;
}

QVariant ShortcutList::getOther(Other, uint) const
{
    return QVariant();
}

bool ShortcutList::setOther(Other, uint, QVariant)
{
    return false;
}

bool ShortcutList::save() const
{
    return writeSettings(QString::null, 0, false, true);
}

KDECORE_EXPORT QString action(StdAccel id)
{
    return name(id);
}
KDECORE_EXPORT QString description(StdAccel id)
{
    return label(id);
}
KDECORE_EXPORT int key(StdAccel id)
{
    return shortcut(id).keyCodeQt();
}
KDECORE_EXPORT int defaultKey(StdAccel id)
{
    return shortcutDefault(id).keyCodeQt();
}

KDECORE_EXPORT bool isEqual(const QKeyEvent *ev, int keyQt)
{
    KKey key1(ev), key2(keyQt);
    return key1 == key2;
}
}
Example #11
0
struct PageFormatInfo {
    KoPageFormat::Format format;
    QPrinter::PageSize qprinter;
    const char* shortName; // Short name
    const char* descriptiveName; // Full name, which will be translated
    qreal width; // in mm
    qreal height; // in mm
};

// NOTES:
// - the width and height of non-ISO formats are rounded
// http://en.wikipedia.org/wiki/Paper_size can help
// - the comments "should be..." indicates the exact values if the inch sizes would be multiplied by 25.4 mm/inch

const PageFormatInfo pageFormatInfo[] = {
    { KoPageFormat::IsoA3Size,       QPrinter::A3,        "A3",        I18N_NOOP2("Page size", "ISO A3"),       297.0,  420.0 },
    { KoPageFormat::IsoA4Size,       QPrinter::A4,        "A4",        I18N_NOOP2("Page size", "ISO A4"),       210.0,  297.0 },
    { KoPageFormat::IsoA5Size,       QPrinter::A5,        "A5",        I18N_NOOP2("Page size", "ISO A5"),       148.0,  210.0 },
    { KoPageFormat::UsLetterSize,    QPrinter::Letter,    "Letter",    I18N_NOOP2("Page size", "US Letter"),    215.9,  279.4 },
    { KoPageFormat::UsLegalSize,     QPrinter::Legal,     "Legal",     I18N_NOOP2("Page size", "US Legal"),     215.9,  355.6 },
    { KoPageFormat::ScreenSize,      QPrinter::A4,        "Screen",    I18N_NOOP2("Page size", "Screen"), PG_A4_HEIGHT, PG_A4_WIDTH }, // Custom, so fall back to A4
    { KoPageFormat::CustomSize,      QPrinter::A4,        "Custom",    I18N_NOOP2("Page size", "Custom"), PG_A4_WIDTH, PG_A4_HEIGHT }, // Custom, so fall back to A4
    { KoPageFormat::IsoB5Size,       QPrinter::B5,        "B5",        I18N_NOOP2("Page size", "ISO B5"),       182.0,  257.0 },
    { KoPageFormat::UsExecutiveSize, QPrinter::Executive, "Executive", I18N_NOOP2("Page size", "US Executive"), 191.0,  254.0 }, // should be 190.5 mm x 254.0 mm
    { KoPageFormat::IsoA0Size,       QPrinter::A0,        "A0",        I18N_NOOP2("Page size", "ISO A0"),       841.0, 1189.0 },
    { KoPageFormat::IsoA1Size,       QPrinter::A1,        "A1",        I18N_NOOP2("Page size", "ISO A1"),       594.0,  841.0 },
    { KoPageFormat::IsoA2Size,       QPrinter::A2,        "A2",        I18N_NOOP2("Page size", "ISO A2"),       420.0,  594.0 },
    { KoPageFormat::IsoA6Size,       QPrinter::A6,        "A6",        I18N_NOOP2("Page size", "ISO A6"),       105.0,  148.0 },
    { KoPageFormat::IsoA7Size,       QPrinter::A7,        "A7",        I18N_NOOP2("Page size", "ISO A7"),        74.0,  105.0 },
    { KoPageFormat::IsoA8Size,       QPrinter::A8,        "A8",        I18N_NOOP2("Page size", "ISO A8"),        52.0,   74.0 },
    { KoPageFormat::IsoA9Size,       QPrinter::A9,        "A9",        I18N_NOOP2("Page size", "ISO A9"),        37.0,   52.0 },
#include <kio/deletejob.h>
#include <kio/job.h>
#include <qstandardpaths.h>
#include <KLocalizedString>

#include <QDebug>

struct ThemeItemNameType {
        const char* m_type;
        const char* m_displayItemName;
        const char* m_themeItemPath;
        const char* m_iconName;
};

const ThemeItemNameType themeCollectionName[] = {
    { "Color Scheme", I18N_NOOP2("plasma name", "Color Scheme"),"colors", "preferences-desktop-color"},
    { "Panel Background", I18N_NOOP2("plasma name", "Panel Background"),"widgets/panel-background", "plasma"},
    { "Kickoff", I18N_NOOP2("plasma name", "Kickoff"), "dialogs/kickoff", "kde"},
    { "Task Items", I18N_NOOP2("plasma name", "Task Items"), "widgets/tasks", "preferences-system-windows"},
    { "Widget Background", I18N_NOOP2("plasma name", "Widget Background"), "widgets/background", "plasma"},
    { "Translucent Background", I18N_NOOP2("plasma name", "Translucent Background"), "widgets/translucentbackground", "plasma"},
    { "Dialog Background", I18N_NOOP2("plasma name", "Dialog Background"), "dialogs/background", "plasma"},
    { "Analog Clock", I18N_NOOP2("plasma name", "Analog Clock"), "widgets/clock", "chronometer"},
    { "Notes", I18N_NOOP2("plasma name", "Notes"), "widgets/notes", "view-pim-notes"},
    { "Tooltip", I18N_NOOP2("plasma name", "Tooltip"), "widgets/tooltip", "plasma"},
    { "Pager", I18N_NOOP2("plasma name", "Pager"), "widgets/pager", "plasma"},
    { "Run Command Dialog", I18N_NOOP2("plasma name", "Run Command Dialog"), "dialogs/krunner", "system-run"},
    { "Shutdown Dialog", I18N_NOOP2("plasma name", "Shutdown Dialog"), "dialogs/shutdowndialog", "system-shutdown"},
    { "Icons", I18N_NOOP2("plasma name", "Icons"), "icons/", "preferences-desktop-icons"},
    { 0, 0,0,0 } // end of data
};
                 QVariant (*getConf)(void *, const char *, const QVariant &),
                 void *ctx)
{
    Q_UNUSED(getConf);
    Q_UNUSED(ctx);
    KGlobal::locale()->insertCatalog("kgreet_ovirtcred");
    return true;
}

static void done()
{
    KGlobal::locale()->removeCatalog("kgreet_ovirtcred");
}

static KGreeterPlugin* create(KGreeterPluginHandler *handler,
                              QWidget *parent,
                              const QString &fixedEntity,
                              KGreeterPlugin::Function func,
                              KGreeterPlugin::Context ctx)
{
    return new KOVirtCredGreeter(handler, parent, fixedEntity, func, ctx);
}

KDE_EXPORT KGreeterPluginInfo kgreeterplugin_info = {
    I18N_NOOP2("@item:inmenu authentication method", "oVirt Authentication"), "ovirtcred",
    KGreeterPluginInfo::Local | KGreeterPluginInfo::Presettable,
    init, done, create
};

#include "kgreet_ovirtcred.moc"
Example #14
0
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//KDE
#include <KLocalizedString>

/*
 * This list is never compiled in Homerun. It only exists to mark Homerun tab
 * titles translatable. The I18nConfigTest in tests/auto ensures this list is
 * kept in sync with the config file.
 */
QStringList sTabNames = QStringList()
    << I18N_NOOP2("Tab title", "Home")
    << I18N_NOOP2("Tab title", "Files")
    << I18N_NOOP2("Tab title", "Applications")
    << I18N_NOOP2("Tab title", "Power")
    ;
Example #15
0
extern "C" KDE_EXPORT int kdemain( int argc, char **argv )
{
  // here we go, construct the Kate version
  QString kateVersion = KateApp::kateVersion();

  KAboutData aboutData ("kate", I18N_NOOP("Kate"), kateVersion.latin1(),
                        I18N_NOOP( "Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2,
                        I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org");

  aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "*****@*****.**", "http://www.babylon2k.de");
  aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "*****@*****.**", "http://www.alweb.dk");
  aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "*****@*****.**","http://stud3.tuwien.ac.at/~e9925371");
  aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "*****@*****.**");
  aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "*****@*****.**" );
  aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "*****@*****.**");
  aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "*****@*****.**");
  aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "*****@*****.**");
  aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "*****@*****.**");
  aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "*****@*****.**" );
  aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "*****@*****.**");
  aboutData.addAuthor ("Christian Gebauer", 0, "*****@*****.**" );
  aboutData.addAuthor ("Simon Hausmann", 0, "*****@*****.**" );
  aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "*****@*****.**");
  aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "*****@*****.**");
  aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "*****@*****.**");
  aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "*****@*****.**");

  aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "*****@*****.**");
  aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "*****@*****.**");
  aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
  aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
  aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
  aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
  aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
  aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
  aboutData.addCredit ("Daniel Naber","","");
  aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
  aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
  aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
  aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");

  aboutData.setTranslator(I18N_NOOP2("NAME OF TRANSLATORS","Your names"), I18N_NOOP2("EMAIL OF TRANSLATORS","Your emails"));

  // command line args init and co
  KCmdLineArgs::init (argc, argv, &aboutData);
  KCmdLineArgs::addCmdLineOptions (options);
  KCmdLineArgs::addTempFileOption();
  KateApp::addCmdLineOptions ();

  // get our command line args ;)
  KCmdLineArgs* args = KCmdLineArgs::parsedArgs();

  // now, first try to contact running kate instance if needed
  if ( args->isSet("use") || (::getenv("KATE_PID")!=0) )
  {
    DCOPClient client;
    client.attach ();

    // get all attached clients ;)
    QCStringList allClients = client.registeredApplications();

    // search for a kate app client, use the first found
    QCString kateApp;

    if ( args->isSet("start") )
    {
      for (unsigned int i=0; i < allClients.count(); i++)
      {
        if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
        {
          DCOPRef ref( allClients[i], "KateApplication" );
          QString s = ref.call( "session" );
          if ( QString(args->getOption("start")) == s )
          {
            kateApp = allClients[i];
            break;
          }
        }
      }
    }
    else if ( (args->isSet("pid")) || (::getenv("KATE_PID") !=0 ) )
    {
      QCString tryApp;
      if ( args->isSet("pid") )
        tryApp = args->getOption("pid");
      else
        tryApp = ::getenv("KATE_PID");

      if ( client.isApplicationRegistered( tryApp.prepend("kate-") ) )
        kateApp = tryApp;
    }
    else
    {
      for (unsigned int i=0; i < allClients.count(); ++i)
      {
        if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
        {
          kateApp = allClients[i];
          break;
        }
      }
    }

    // found a matching kate client ;)
    if (!kateApp.isEmpty())
    {
      kdDebug () << "kate app: " << kateApp << endl;
      // make kdeinit happy
      client.registerAs( "kate" );

      DCOPRef kRef (kateApp, "KateApplication");

      if (args->isSet ("start"))
        kRef.call( "activateSession", QString (args->getOption("start")) );

      QString enc = args->isSet("encoding") ? args->getOption("encoding") : QCString("");

      bool tempfileSet = KCmdLineArgs::isTempFileSet();

      for (int z=0; z<args->count(); z++)
        kRef.call( "openURL", args->url(z), enc, tempfileSet );

      if( args->isSet( "stdin" ) )
      {
        QTextIStream input(stdin);

        // set chosen codec
        QTextCodec *codec = args->isSet("encoding") ? QTextCodec::codecForName(args->getOption("encoding")) : 0;

        if (codec)
          input.setCodec (codec);

        QString line;
        QString text;

        do
        {
          line = input.readLine();
          text.append( line + "\n" );
        } while( !line.isNull() );

        kRef.call( "openInput", text );
      }

      int line = 0;
      int column = 0;
      bool nav = false;

      if (args->isSet ("line"))
      {
        line = args->getOption ("line").toInt();
        nav = true;
      }

      if (args->isSet ("column"))
      {
        column = args->getOption ("column").toInt();
        nav = true;
      }

      if (nav)
         kRef.call( "setCursor", line, column );

      // since the user tried to open a document, let us assume [s]he
      // wants to see that document.
      // ### what to do about the infamous focus stealing prevention?
      uint mwn = kRef.call("activeMainWindowNumber");
      QCString smwn;
      DCOPRef wRef( kateApp, QCString( "__KateMainWindow#") + smwn.setNum(mwn) );
      if ( wRef.call("minimized") )
      {
        if ( wRef.call( "maximized" ) )
          wRef.call( "maximize" );
        else
          wRef.call("restore");
      }
      wRef.call( "raise" );

      // stop startup notification
      KStartupInfo::appStarted(  );

      return 0;
    }
  }

  // construct the real kate app object ;)
  KateApp app (args);

  // app execution should already end :)
  if (app.shouldExit())
  {
    return 0;
  }

  // execute ourself ;)
  return app.exec();
}
Example #16
0
namespace KStandardShortcut
{

struct KStandardShortcutInfo
{
    //! The standard shortcut id. @see StandardShortcut
    StandardShortcut id;

    /** 
     * Unique name for the given accel. The name is used to save the user
     * settings. It's not representable. Use description for that.
     * @warning NEVER EVER CHANGE IT OR TRANSLATE IT!
     */
    const char* name;

    //! Context for the translation
    const char* translation_context;

    //! Localized label for user-visible display
    const char* description;

    //! The keys for this shortcut
    int cutDefault, cutDefault2;

    //! A shortcut that is created with @a cutDefault and @cutDefault2
    KShortcut cut;

    //! If this struct is initialized. If not initialized @cut is not valid
    bool isInitialized;
};

//! We need to remember the context to get the correct translation.
#undef I18N_NOOP2
#define I18N_NOOP2(comment,x) comment, x

#define CTRL(x) Qt::CTRL+Qt::Key_##x
#define SHIFT(x) Qt::SHIFT+Qt::Key_##x
#define CTRLSHIFT(x) Qt::CTRL+Qt::SHIFT+Qt::Key_##x
#define ALT(x) Qt::ALT+Qt::Key_##x
#define ALTSHIFT(x) Qt::ALT+Qt::SHIFT+Qt::Key_##x

/** Array of predefined KStandardShortcutInfo objects, which cover all
    the "standard" accelerators. Each enum value from StandardShortcut
    should appear in this table.
*/
// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
// Read the comments of the big enum in kstandardshortcut.h before you change anything!
static KStandardShortcutInfo g_infoStandardShortcut[] =
{
//Group File,
    {AccelNone, 0      , 0                   , 0       , 0      , 0           , KShortcut(), false },
    { Open    , "Open" , I18N_NOOP2("@action", "Open") , CTRL(O), 0           , KShortcut(), false }    ,
    { New     , "New"  , I18N_NOOP2("@action", "New")  , CTRL(N), 0           , KShortcut(), false }    ,
    { Close   , "Close", I18N_NOOP2("@action", "Close"), CTRL(W), CTRL(Escape), KShortcut(), false }    ,
    { Save    , "Save" , I18N_NOOP2("@action", "Save") , CTRL(S), 0           , KShortcut(), false }    ,
    { Print   , "Print", I18N_NOOP2("@action", "Print"), CTRL(P), 0           , KShortcut(), false }    ,
    { Quit    , "Quit" , I18N_NOOP2("@action", "Quit") , CTRL(Q), 0           , KShortcut(), false }    ,

//Group Edit
    { Undo             , "Undo"             , I18N_NOOP2("@action", "Undo")                 , CTRL(Z)          , 0            , KShortcut(), false },
    { Redo             , "Redo"             , I18N_NOOP2("@action", "Redo")                 , CTRLSHIFT(Z)     , 0            , KShortcut(), false },
    { Cut              , "Cut"              , I18N_NOOP2("@action", "Cut")                  , CTRL(X)          , SHIFT(Delete), KShortcut(), false },
    { Copy             , "Copy"             , I18N_NOOP2("@action", "Copy")                 , CTRL(C)          , CTRL(Insert) , KShortcut(), false },
    { Paste            , "Paste"            , I18N_NOOP2("@action", "Paste")                , CTRL(V)          , SHIFT(Insert), KShortcut(), false },
    { PasteSelection   , "Paste Selection"  , I18N_NOOP2("@action", "Paste Selection")      , CTRLSHIFT(Insert), 0            , KShortcut(), false },

    { SelectAll        , "SelectAll"        , I18N_NOOP2("@action", "Select All")           , CTRL(A)          , 0            , KShortcut(), false },
    { Deselect         , "Deselect"         , I18N_NOOP2("@action", "Deselect")             , CTRLSHIFT(A)     , 0            , KShortcut(), false },
    { DeleteWordBack   , "DeleteWordBack"   , I18N_NOOP2("@action", "Delete Word Backwards"), CTRL(Backspace)  , 0            , KShortcut(), false },
    { DeleteWordForward, "DeleteWordForward", I18N_NOOP2("@action", "Delete Word Forward")  , CTRL(Delete)     , 0            , KShortcut(), false },

    { Find             , "Find"             , I18N_NOOP2("@action", "Find")                 , CTRL(F)          , 0            , KShortcut(), false },
    { FindNext         , "FindNext"         , I18N_NOOP2("@action", "Find Next")            , Qt::Key_F3       , 0            , KShortcut(), false },
    { FindPrev         , "FindPrev"         , I18N_NOOP2("@action", "Find Prev")            , SHIFT(F3)        , 0            , KShortcut(), false },
    { Replace          , "Replace"          , I18N_NOOP2("@action", "Replace")              , CTRL(R)          , 0            , KShortcut(), false },

//Group Navigation
    { Home           , "Home"                 , I18N_NOOP2("@action Go to main page"      , "Home")                 , ALT(Home)       , Qt::Key_HomePage  , KShortcut(), false },
    { Begin          , "Begin"                , I18N_NOOP2("@action Beginning of document", "Begin")                , CTRL(Home)      , 0                 , KShortcut(), false },
    { End            , "End"                  , I18N_NOOP2("@action End of document"      , "End")                  , CTRL(End)       , 0                 , KShortcut(), false },
    { Prior          , "Prior"                , I18N_NOOP2("@action"                      , "Prior")                , Qt::Key_PageUp  , 0                 , KShortcut(), false },
    { Next           , "Next"                 , I18N_NOOP2("@action Opposite to Prior"    , "Next")                 , Qt::Key_PageDown, 0                 , KShortcut(), false },

    { Up             , "Up"                   , I18N_NOOP2("@action"                      , "Up")                   , ALT(Up)         , 0                 , KShortcut(), false },
    { Back           , "Back"                 , I18N_NOOP2("@action"                      , "Back")                 , ALT(Left)       , Qt::Key_Back      , KShortcut(), false },
    { Forward        , "Forward"              , I18N_NOOP2("@action"                      , "Forward")              , ALT(Right)      , Qt::Key_Forward   , KShortcut(), false },
    { Reload         , "Reload"               , I18N_NOOP2("@action"                      , "Reload")               , Qt::Key_F5      , Qt::Key_Refresh   , KShortcut(), false },

    { BeginningOfLine, "BeginningOfLine"      , I18N_NOOP2("@action"                      , "Beginning of Line")    , Qt::Key_Home    , 0                 , KShortcut(), false },
    { EndOfLine      , "EndOfLine"            , I18N_NOOP2("@action"                      , "End of Line")          , Qt::Key_End     , 0                 , KShortcut(), false },
    { GotoLine       , "GotoLine"             , I18N_NOOP2("@action"                      , "Go to Line")           , CTRL(G)         , 0                 , KShortcut(), false },
    { BackwardWord   , "BackwardWord"         , I18N_NOOP2("@action"                      , "Backward Word")        , CTRL(Left)      , 0                 , KShortcut(), false },
    { ForwardWord    , "ForwardWord"          , I18N_NOOP2("@action"                      , "Forward Word")         , CTRL(Right)     , 0                 , KShortcut(), false },

    { AddBookmark    , "AddBookmark"          , I18N_NOOP2("@action"                      , "Add Bookmark")         , CTRL(B)         , 0                 , KShortcut(), false },
    { ZoomIn         , "ZoomIn"               , I18N_NOOP2("@action"                      , "Zoom In")              , CTRL(Plus)      , CTRL(Equal)       , KShortcut(), false },
    { ZoomOut        , "ZoomOut"              , I18N_NOOP2("@action"                      , "Zoom Out")             , CTRL(Minus)     , 0                 , KShortcut(), false },
    { FullScreen     , "FullScreen"           , I18N_NOOP2("@action"                      , "Full Screen Mode")     , CTRLSHIFT(F)    , 0                 , KShortcut(), false },

    { ShowMenubar    , "ShowMenubar"          , I18N_NOOP2("@action"                      , "Show Menu Bar")        , CTRL(M)         , 0                 , KShortcut(), false },
    { TabNext        , "Activate Next Tab"    , I18N_NOOP2("@action"                      , "Activate Next Tab")    , CTRL(Period)    , CTRL(BracketRight), KShortcut(), false },
    { TabPrev        , "Activate Previous Tab", I18N_NOOP2("@action"                      , "Activate Previous Tab"), CTRL(Comma)     , CTRL(BracketLeft) , KShortcut(), false },

    //Group Help
    { Help           , "Help"                 , I18N_NOOP2("@action"                      , "Help")                 , Qt::Key_F1      , 0                 , KShortcut(), false },
    { WhatsThis      , "WhatsThis"            , I18N_NOOP2("@action"                      , "What's This")          , SHIFT(F1)       , 0                 , KShortcut(), false },

//Group TextCompletion
    { TextCompletion           , "TextCompletion"           , I18N_NOOP2("@action", "Text Completion")          , CTRL(E)     , 0, KShortcut(), false },
    { PrevCompletion           , "PrevCompletion"           , I18N_NOOP2("@action", "Previous Completion Match"), CTRL(Up)    , 0, KShortcut(), false },
    { NextCompletion           , "NextCompletion"           , I18N_NOOP2("@action", "Next Completion Match")    , CTRL(Down)  , 0, KShortcut(), false },
    { SubstringCompletion      , "SubstringCompletion"      , I18N_NOOP2("@action", "Substring Completion")     , CTRL(T)     , 0, KShortcut(), false },

    { RotateUp                 , "RotateUp"                 , I18N_NOOP2("@action", "Previous Item in List")    , Qt::Key_Up  , 0, KShortcut(), false },
    { RotateDown               , "RotateDown"               , I18N_NOOP2("@action", "Next Item in List")        , Qt::Key_Down, 0, KShortcut(), false },

    { OpenRecent               , "OpenRecent"               , I18N_NOOP2("@action", "Open Recent")               , 0           , 0, KShortcut(), false },
    { SaveAs                   , "SaveAs"                   , I18N_NOOP2("@action", "Save As")                   , 0           , 0, KShortcut(), false },
    { Revert                   , "Revert"                   , I18N_NOOP2("@action", "Revert")                   , 0           , 0, KShortcut(), false },
    { PrintPreview             , "PrintPreview"             , I18N_NOOP2("@action", "Print Preview")             , 0           , 0, KShortcut(), false },
    { Mail                     , "Mail"                     , I18N_NOOP2("@action", "Mail")                     , 0           , 0, KShortcut(), false },
    { Clear                    , "Clear"                    , I18N_NOOP2("@action", "Clear")                    , 0           , 0, KShortcut(), false },
    { ActualSize               , "ActualSize"               , I18N_NOOP2("@action", "Actual Size")               , 0           , 0, KShortcut(), false },
    { FitToPage                , "FitToPage"                , I18N_NOOP2("@action", "Fit To Page")                , 0           , 0, KShortcut(), false },
    { FitToWidth               , "FitToWidth"               , I18N_NOOP2("@action", "Fit To Width")               , 0           , 0, KShortcut(), false },
    { FitToHeight              , "FitToHeight"              , I18N_NOOP2("@action", "Fit To Height")              , 0           , 0, KShortcut(), false },
    { Zoom                     , "Zoom"                     , I18N_NOOP2("@action", "Zoom")                     , 0           , 0, KShortcut(), false },
    { Goto                     , "Goto"                     , I18N_NOOP2("@action", "Goto")                     , 0           , 0, KShortcut(), false },
    { GotoPage                 , "GotoPage"                 , I18N_NOOP2("@action", "Goto Page")                 , 0           , 0, KShortcut(), false },
    { DocumentBack             , "DocumentBack"             , I18N_NOOP2("@action", "Document Back")             , ALTSHIFT(Left), 0, KShortcut(), false },
    { DocumentForward          , "DocumentForward"          , I18N_NOOP2("@action", "Document Forward")          , ALTSHIFT(Right), 0, KShortcut(), false },
    { EditBookmarks            , "EditBookmarks"            , I18N_NOOP2("@action", "Edit Bookmarks")            , 0           , 0, KShortcut(), false },
    { Spelling                 , "Spelling"                 , I18N_NOOP2("@action", "Spelling")                 , 0           , 0, KShortcut(), false },
    { ShowToolbar              , "ShowToolbar"              , I18N_NOOP2("@action", "Show Toolbar")              , 0           , 0, KShortcut(), false },
    { ShowStatusbar            , "ShowStatusbar"            , I18N_NOOP2("@action", "Show Statusbar")            , 0           , 0, KShortcut(), false },
    { SaveOptions              , "SaveOptions"              , I18N_NOOP2("@action", "Save Options")              , 0           , 0, KShortcut(), false },
    { KeyBindings              , "KeyBindings"              , I18N_NOOP2("@action", "Key Bindings")              , 0           , 0, KShortcut(), false },
    { Preferences              , "Preferences"              , I18N_NOOP2("@action", "Preferences")              , 0           , 0, KShortcut(), false },
    { ConfigureToolbars        , "ConfigureToolbars"        , I18N_NOOP2("@action", "Configure Toolbars")        , 0           , 0, KShortcut(), false },
    { ConfigureNotifications   , "ConfigureNotifications"   , I18N_NOOP2("@action", "Configure Notifications")   , 0           , 0, KShortcut(), false },
    { TipofDay                 , "TipofDay"                 , I18N_NOOP2("@action", "Tip Of Day")                 , 0           , 0, KShortcut(), false },
    { ReportBug                , "ReportBug"                , I18N_NOOP2("@action", "Report Bug")                , 0           , 0, KShortcut(), false },
    { SwitchApplicationLanguage, "SwitchApplicationLanguage", I18N_NOOP2("@action", "Switch Application Language"), 0           , 0, KShortcut(), false },
    { AboutApp                 , "AboutApp"                 , I18N_NOOP2("@action", "About Application")                 , 0           , 0, KShortcut(), false },
    { AboutKDE                 , "AboutKDE"                 , I18N_NOOP2("@action", "About KDE")                 , 0           , 0, KShortcut(), false },

    //dummy entry to catch simple off-by-one errors. Insert new entries before this line.
    { AccelNone                , 0                          , 0                   , 0                           , 0, 0, KShortcut(), false }
};


/** Search for the KStandardShortcutInfo object associated with the given @p id.
    Return a dummy entry with no name and an empty shortcut if @p id is invalid.
*/
static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)
{
    if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) ||
             id < 0) {
        kWarning(125) << "KStandardShortcut: id not found!";
        return &g_infoStandardShortcut[AccelNone];
    } else
        return &g_infoStandardShortcut[id];
}

/** Initialize the accelerator @p id by checking if it is overridden
    in the configuration file (and if it isn't, use the default).
    On X11, if QApplication was initialized with GUI disabled,
    the default will always be used.
*/
static void initialize(StandardShortcut id)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);

    // All three are needed.
    if (info->id!=AccelNone) {
        Q_ASSERT(info->description);
        Q_ASSERT(info->translation_context);
        Q_ASSERT(info->name);
    }

    KConfigGroup cg(KGlobal::config(), "Shortcuts");

#ifdef Q_WS_X11
    // Code within this block breaks if we aren't running in GUI mode.
    if(QX11Info::display() && cg.hasKey(info->name))
#else
    if(cg.hasKey(info->name))
#endif
    {
        QString s = cg.readEntry(info->name);
        if (s != "none")
            info->cut = KShortcut(s);
        else
            info->cut = KShortcut();
    } else {
        info->cut = hardcodedDefaultShortcut(id);
    }

    info->isInitialized = true;
}

void saveShortcut(StandardShortcut id, const KShortcut &newShortcut)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
    // If the action has no standard shortcut associated there is nothing to
    // save
    if(info->id == AccelNone)
        return;

    KConfigGroup cg(KGlobal::config(), "Shortcuts");

    info->cut = newShortcut;
    bool sameAsDefault = (newShortcut == hardcodedDefaultShortcut(id));

    if (sameAsDefault) {
        // If the shortcut is the equal to the hardcoded one we remove it from
        // kdeglobal if necessary and return.
        if(cg.hasKey(info->name))
            cg.deleteEntry(info->name, KConfig::Global|KConfig::Persistent);

        return;
    }

    // Write the changed shortcut to kdeglobals
    cg.writeEntry(info->name, info->cut.toString(), KConfig::Global|KConfig::Persistent);
}

QString name(StandardShortcut id)
{
    return guardedStandardShortcutInfo(id)->name;
}

QString label(StandardShortcut id)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo( id );
    return i18nc(
        info->translation_context,
        info->description);
}

// TODO: Add psWhatsThis entry to KStandardShortcutInfo
QString whatsThis( StandardShortcut /*id*/ )
{
//  KStandardShortcutInfo* info = guardedStandardShortcutInfo( id );
//  if( info && info->whatsThis )
//      return i18n(info->whatsThis);
//  else
        return QString();
}

const KShortcut &shortcut(StandardShortcut id)
{
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);

    if(!info->isInitialized)
        initialize(id);

    return info->cut;
}

StandardShortcut find(const QKeySequence &seq)
{
    if( !seq.isEmpty() ) {
        for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++) {
            StandardShortcut id = g_infoStandardShortcut[i].id;
            if( id != AccelNone ) {
                if(!g_infoStandardShortcut[i].isInitialized)
                    initialize(id);
                if(g_infoStandardShortcut[i].cut.contains(seq))
                    return id;
            }
        }
    }
    return AccelNone;
}

StandardShortcut find(const char *keyName)
{
    for(uint i = 0; i < sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo); i++)
        if (qstrcmp(g_infoStandardShortcut[i].name, keyName))
            return g_infoStandardShortcut[i].id;

    return AccelNone;
}

KShortcut hardcodedDefaultShortcut(StandardShortcut id)
{
    KShortcut cut;
    KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);

    return KShortcut(info->cutDefault, info->cutDefault2);
}

const KShortcut& open()                  { return shortcut( Open ); }
const KShortcut& openNew()               { return shortcut( New ); }
const KShortcut& close()                 { return shortcut( Close ); }
const KShortcut& save()                  { return shortcut( Save ); }
const KShortcut& print()                 { return shortcut( Print ); }
const KShortcut& quit()                  { return shortcut( Quit ); }
const KShortcut& cut()                   { return shortcut( Cut ); }
const KShortcut& copy()                  { return shortcut( Copy ); }
const KShortcut& paste()                 { return shortcut( Paste ); }
const KShortcut& pasteSelection()        { return shortcut( PasteSelection ); }
const KShortcut& deleteWordBack()        { return shortcut( DeleteWordBack ); }
const KShortcut& deleteWordForward()     { return shortcut( DeleteWordForward ); }
const KShortcut& undo()                  { return shortcut( Undo ); }
const KShortcut& redo()                  { return shortcut( Redo ); }
const KShortcut& find()                  { return shortcut( Find ); }
const KShortcut& findNext()              { return shortcut( FindNext ); }
const KShortcut& findPrev()              { return shortcut( FindPrev ); }
const KShortcut& replace()               { return shortcut( Replace ); }
const KShortcut& home()                  { return shortcut( Home ); }
const KShortcut& begin()                 { return shortcut( Begin ); }
const KShortcut& end()                   { return shortcut( End ); }
const KShortcut& beginningOfLine()       { return shortcut( BeginningOfLine ); }
const KShortcut& endOfLine()             { return shortcut( EndOfLine ); }
const KShortcut& prior()                 { return shortcut( Prior ); }
const KShortcut& next()                  { return shortcut( Next ); }
const KShortcut& backwardWord()          { return shortcut( BackwardWord ); }
const KShortcut& forwardWord()           { return shortcut( ForwardWord ); }
const KShortcut& gotoLine()              { return shortcut( GotoLine ); }
const KShortcut& addBookmark()           { return shortcut( AddBookmark ); }
const KShortcut& tabNext()               { return shortcut( TabNext ); }
const KShortcut& tabPrev()               { return shortcut( TabPrev ); }
const KShortcut& fullScreen()            { return shortcut( FullScreen ); }
const KShortcut& zoomIn()                { return shortcut( ZoomIn ); }
const KShortcut& zoomOut()               { return shortcut( ZoomOut ); }
const KShortcut& help()                  { return shortcut( Help ); }
const KShortcut& completion()            { return shortcut( TextCompletion ); }
const KShortcut& prevCompletion()        { return shortcut( PrevCompletion ); }
const KShortcut& nextCompletion()        { return shortcut( NextCompletion ); }
const KShortcut& rotateUp()              { return shortcut( RotateUp ); }
const KShortcut& rotateDown()            { return shortcut( RotateDown ); }
const KShortcut& substringCompletion()   { return shortcut( SubstringCompletion ); }
const KShortcut& whatsThis()             { return shortcut( WhatsThis ); }
const KShortcut& reload()                { return shortcut( Reload ); }
const KShortcut& selectAll()             { return shortcut( SelectAll ); }
const KShortcut& up()                    { return shortcut( Up ); }
const KShortcut& back()                  { return shortcut( Back ); }
const KShortcut& forward()               { return shortcut( Forward ); }
const KShortcut& showMenubar()           { return shortcut( ShowMenubar ); }

}
Example #17
0
                                              QStringLiteral("Home"), I18N_NOOP2("KFile System Bookmarks", "Home"),
                                              QUrl::fromLocalFile(QDir::homePath()), QStringLiteral("user-home"));
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              QStringLiteral("Network"), I18N_NOOP2("KFile System Bookmarks", "Network"),
                                              QUrl(QStringLiteral("remote:/")), QStringLiteral("network-workgroup"));
#if defined(_WIN32_WCE)
        // adding drives
        foreach (const QFileInfo &info, QDir::drives()) {
            QString driveIcon = "drive-harddisk";
            KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                                  info.absoluteFilePath(), info.absoluteFilePath(),
                                                  QUrl::fromLocalFile(info.absoluteFilePath()), driveIcon);
        }
#elif !defined(Q_OS_WIN)
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              QStringLiteral("Root"), I18N_NOOP2("KFile System Bookmarks", "Root"),
                                              QUrl::fromLocalFile(QStringLiteral("/")), QStringLiteral("folder-red"));
#endif
        KFilePlacesItem::createSystemBookmark(d->bookmarkManager,
                                              QStringLiteral("Trash"), I18N_NOOP2("KFile System Bookmarks", "Trash"),
                                              QUrl(QStringLiteral("trash:/")), QStringLiteral("user-trash"));

        // Force bookmarks to be saved. If on open/save dialog and the bookmarks are not saved, QFile::exists
        // will always return false, which opening/closing all the time the open/save dialog would case the
        // bookmarks to be added once each time, having lots of times each bookmark. (ereslibre)
        d->bookmarkManager->saveAs(file);
    }

    QString predicate(QString::fromLatin1("[[[[ StorageVolume.ignored == false AND [ StorageVolume.usage == 'FileSystem' OR StorageVolume.usage == 'Encrypted' ]]"
                      " OR "
                      "[ IS StorageAccess AND StorageDrive.driveType == 'Floppy' ]]"
Example #18
0
File: main.cpp Project: KDE/libqapt
 ***************************************************************************/

#include "PluginHelper.h"

#include <QApplication>
#include <QCommandLineParser>
#include <QIcon>

#include <KAboutData>
#include <KLocalizedString>

#include <gst/gst.h>
#include <gst/pbutils/install-plugins.h>

static const char description[] =
    I18N_NOOP2("@info", "A GStreamer codec installer using QApt");

static const char version[] = CMAKE_PROJECT_VERSION;

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    app.setWindowIcon(QIcon::fromTheme("applications-other"));

    KLocalizedString::setApplicationDomain("qapt-gst-helper");

    KAboutData aboutData("qapt-gst-helper",
                         i18nc("@title", "QApt Codec Searcher"),
                         version,
                         i18nc("@info", description),
                         KAboutLicense::LicenseKey::GPL,
Example #19
0
#include <X11/Xlib.h> 

// defined in qapplication_x11.cpp
typedef int (*QX11EventFilter) (XEvent*);
extern QX11EventFilter tqt_set_x11_event_filter (QX11EventFilter filter);
#endif

struct ColorPaletteNameType
{
    const char* m_fileName;
    const char* m_displayName;
};

const ColorPaletteNameType colorPaletteName[]=
{
    { "Recent_Colors", I18N_NOOP2( "palette name", "* Recent Colors *" ) },
    { "Custom_Colors", I18N_NOOP2( "palette name", "* Custom Colors *" ) },
    { "40.colors",     I18N_NOOP2( "palette name", "Forty Colors" ) },
    { "Rainbow.colors",I18N_NOOP2( "palette name", "Rainbow Colors" ) },
    { "Royal.colors",  I18N_NOOP2( "palette name", "Royal Colors" ) },
    { "Web.colors",    I18N_NOOP2( "palette name", "Web Colors" ) },
    { 0, 0 } // end of data
};

const int recentColorIndex = 0;
const int customColorIndex = 1;

class KColorSpinBox : public TQSpinBox
{
public:
  KColorSpinBox(int minValue, int maxValue, int step, TQWidget* parent)