I think I went from the scale itself. For example, D major starts on D, and the there is F# and C# in the key signature, so I know that those two notes are sharped. A triad in root position skips every second note, and there is a fifth from the top to bottom note. So to get familiar with it I would play and listen. So in D major I'd form the 1st triad on the bottom:
DF#A (because we know F is sharped). We can hear it's major. D to F# is a major 3. major.
EGB We hear it's minor. The triad from E to G is a minor third.
F#AC We hear it's minor.
GBD We hear it's major.
AC#E Because C is sharped in the key of D major. A to C# is a major 3.
BDF We hear it's minor.
C#EG It's a diminished chord because C# to E is a minor third, and C# to G is a tritone (C# to G# is a Perfect 5.
We could do this with any other major key. We will always have the same pattern: I, ii, iii, IV, V, vi, viio. You can work it out this way. You have to know your key signatures first like Nystul suggested.